nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv, fetchgit, cmake, pkgconfig, gtk3, darwin }:
2
3let
4 shortName = "libui";
5 version = "3.1a";
6 backend = if stdenv.isDarwin then "darwin" else "unix";
7in
8 stdenv.mkDerivation rec {
9 name = "${shortName}-${version}";
10 src = fetchgit {
11 url = "https://github.com/andlabs/libui.git";
12 rev = "6ebdc96b93273c3cedf81159e7843025caa83058";
13 sha256 = "1lpbfa298c61aarlzgp7vghrmxg1274pzxh1j9isv8x758gk6mfn";
14 };
15
16 buildInputs = [ cmake pkgconfig ] ++
17 (if stdenv.isDarwin then [darwin.apple_sdk.frameworks.Cocoa] else [gtk3]);
18
19 preConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
20 sed -i 's/set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8")//' ./CMakeLists.txt
21 '';
22 cmakeFlags = stdenv.lib.optionals stdenv.isDarwin [
23 "-DCMAKE_OSX_SYSROOT="
24 "-DCMAKE_OSX_DEPLOYMENT_TARGET="
25 ];
26
27 installPhase = ''
28 mkdir -p $out/{include,lib}
29 mkdir -p $out/lib/pkgconfig
30 '' + stdenv.lib.optionalString stdenv.isLinux ''
31 mv ./out/${shortName}.so.0 $out/lib/
32 ln -s $out/lib/${shortName}.so.0 $out/lib/${shortName}.so
33 '' + stdenv.lib.optionalString stdenv.isDarwin ''
34 mv ./out/${shortName}.A.dylib $out/lib/
35 ln -s $out/lib/${shortName}.A.dylib $out/lib/${shortName}.dylib
36 '' + ''
37 cp $src/ui.h $out/include
38 cp $src/ui_${backend}.h $out/include
39
40 cp ${./libui.pc} $out/lib/pkgconfig/${shortName}.pc
41 substituteInPlace $out/lib/pkgconfig/${shortName}.pc \
42 --subst-var-by out $out \
43 --subst-var-by version "${version}"
44 '';
45 postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
46 install_name_tool -id $out/lib/${shortName}.A.dylib $out/lib/${shortName}.A.dylib
47 '';
48
49 meta = {
50 homepage = https://github.com/andlabs/libui;
51 description = "Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.";
52 platforms = stdenv.lib.platforms.unix;
53 };
54 }