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