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