2016-09-28 08:00:01 +01:00
|
|
|
{ stdenv, fetchgit, cmake, pkgconfig, gtk3, darwin }:
|
2016-07-16 10:04:05 +01:00
|
|
|
|
2016-07-22 23:41:02 +01:00
|
|
|
let
|
|
|
|
shortName = "libui";
|
|
|
|
version = "3.1a";
|
2016-09-28 08:00:01 +01:00
|
|
|
backend = if stdenv.isDarwin then "darwin" else "unix";
|
2016-07-22 23:41:02 +01:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "${shortName}-${version}";
|
|
|
|
src = fetchgit {
|
|
|
|
url = "https://github.com/andlabs/libui.git";
|
|
|
|
rev = "6ebdc96b93273c3cedf81159e7843025caa83058";
|
|
|
|
sha256 = "1lpbfa298c61aarlzgp7vghrmxg1274pzxh1j9isv8x758gk6mfn";
|
|
|
|
};
|
2016-07-16 10:04:05 +01:00
|
|
|
|
2017-09-05 22:26:13 +01:00
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
|
|
|
buildInputs = [ cmake ] ++
|
2018-03-14 19:15:06 +00:00
|
|
|
(if backend == "darwin" then [darwin.apple_sdk.frameworks.Cocoa]
|
2018-03-14 20:29:44 +00:00
|
|
|
else if backend == "unix" then [gtk3]
|
|
|
|
else null);
|
2016-09-28 08:00:01 +01:00
|
|
|
|
|
|
|
preConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
|
|
|
|
sed -i 's/set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8")//' ./CMakeLists.txt
|
|
|
|
'';
|
|
|
|
cmakeFlags = stdenv.lib.optionals stdenv.isDarwin [
|
|
|
|
"-DCMAKE_OSX_SYSROOT="
|
|
|
|
"-DCMAKE_OSX_DEPLOYMENT_TARGET="
|
|
|
|
];
|
2016-07-16 10:04:05 +01:00
|
|
|
|
2016-07-22 23:41:02 +01:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/{include,lib}
|
|
|
|
mkdir -p $out/lib/pkgconfig
|
2016-09-28 08:00:01 +01:00
|
|
|
'' + stdenv.lib.optionalString stdenv.isLinux ''
|
2016-07-22 23:41:02 +01:00
|
|
|
mv ./out/${shortName}.so.0 $out/lib/
|
|
|
|
ln -s $out/lib/${shortName}.so.0 $out/lib/${shortName}.so
|
2016-09-28 08:00:01 +01:00
|
|
|
'' + stdenv.lib.optionalString stdenv.isDarwin ''
|
|
|
|
mv ./out/${shortName}.A.dylib $out/lib/
|
|
|
|
ln -s $out/lib/${shortName}.A.dylib $out/lib/${shortName}.dylib
|
|
|
|
'' + ''
|
2016-07-22 23:41:02 +01:00
|
|
|
cp $src/ui.h $out/include
|
2016-09-28 08:00:01 +01:00
|
|
|
cp $src/ui_${backend}.h $out/include
|
2016-07-22 23:41:02 +01:00
|
|
|
|
|
|
|
cp ${./libui.pc} $out/lib/pkgconfig/${shortName}.pc
|
|
|
|
substituteInPlace $out/lib/pkgconfig/${shortName}.pc \
|
|
|
|
--subst-var-by out $out \
|
|
|
|
--subst-var-by version "${version}"
|
|
|
|
'';
|
2016-09-28 08:00:01 +01:00
|
|
|
postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
|
|
|
|
install_name_tool -id $out/lib/${shortName}.A.dylib $out/lib/${shortName}.A.dylib
|
|
|
|
'';
|
2016-07-22 23:41:02 +01:00
|
|
|
|
2018-10-11 13:28:08 +01:00
|
|
|
meta = with stdenv.lib; {
|
2016-07-22 23:41:02 +01:00
|
|
|
homepage = https://github.com/andlabs/libui;
|
|
|
|
description = "Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.";
|
2018-10-11 13:28:08 +01:00
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.unix;
|
2016-07-22 23:41:02 +01:00
|
|
|
};
|
|
|
|
}
|