Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-18.03 55 lines 2.0 kB view raw
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 nativeBuildInputs = [ pkgconfig ]; 17 buildInputs = [ cmake ] ++ 18 (if stdenv.isDarwin then [darwin.apple_sdk.frameworks.Cocoa] else [gtk3]); 19 20 preConfigure = stdenv.lib.optionalString stdenv.isDarwin '' 21 sed -i 's/set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8")//' ./CMakeLists.txt 22 ''; 23 cmakeFlags = stdenv.lib.optionals stdenv.isDarwin [ 24 "-DCMAKE_OSX_SYSROOT=" 25 "-DCMAKE_OSX_DEPLOYMENT_TARGET=" 26 ]; 27 28 installPhase = '' 29 mkdir -p $out/{include,lib} 30 mkdir -p $out/lib/pkgconfig 31 '' + stdenv.lib.optionalString stdenv.isLinux '' 32 mv ./out/${shortName}.so.0 $out/lib/ 33 ln -s $out/lib/${shortName}.so.0 $out/lib/${shortName}.so 34 '' + stdenv.lib.optionalString stdenv.isDarwin '' 35 mv ./out/${shortName}.A.dylib $out/lib/ 36 ln -s $out/lib/${shortName}.A.dylib $out/lib/${shortName}.dylib 37 '' + '' 38 cp $src/ui.h $out/include 39 cp $src/ui_${backend}.h $out/include 40 41 cp ${./libui.pc} $out/lib/pkgconfig/${shortName}.pc 42 substituteInPlace $out/lib/pkgconfig/${shortName}.pc \ 43 --subst-var-by out $out \ 44 --subst-var-by version "${version}" 45 ''; 46 postInstall = stdenv.lib.optionalString stdenv.isDarwin '' 47 install_name_tool -id $out/lib/${shortName}.A.dylib $out/lib/${shortName}.A.dylib 48 ''; 49 50 meta = { 51 homepage = https://github.com/andlabs/libui; 52 description = "Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports."; 53 platforms = stdenv.lib.platforms.unix; 54 }; 55 }