forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / development / libraries / libui / default.nix
blob77197986343f62d06b8658d95a51e55823004971
1 { lib, stdenv, fetchFromGitHub, cmake, pkg-config, gtk3, Cocoa }:
3 let
4   backend   = if stdenv.hostPlatform.isDarwin then "darwin" else "unix";
5 in
7 stdenv.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   };
17   nativeBuildInputs = [ cmake pkg-config ];
18   propagatedBuildInputs = lib.optional stdenv.hostPlatform.isLinux gtk3
19     ++ lib.optionals stdenv.hostPlatform.isDarwin [ Cocoa ];
21   preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin ''
22     sed -i 's/set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8")//' ./CMakeLists.txt
23   '';
25   installPhase = ''
26     mkdir -p $out/{include,lib}
27     mkdir -p $out/lib/pkgconfig
28   '' + lib.optionalString stdenv.hostPlatform.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.hostPlatform.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
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.hostPlatform.isDarwin ''
44     install_name_tool -id $out/lib/libui.A.dylib $out/lib/libui.A.dylib
45   '';
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   };