nixpkgs/pkgs/development/libraries/libui/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

54 lines
1.7 KiB
Nix

{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, gtk3, Cocoa }:
let
backend = if stdenv.hostPlatform.isDarwin then "darwin" else "unix";
in
stdenv.mkDerivation rec {
pname = "libui";
version = "4.1a";
src = fetchFromGitHub {
owner = "andlabs";
repo = "libui";
rev = "alpha4.1";
sha256 = "0bm6xvqk4drg2kw6d304x6mlfal7gh8mbl5a9f0509smmdzgdkwm";
};
nativeBuildInputs = [ cmake pkg-config ];
propagatedBuildInputs = lib.optional stdenv.hostPlatform.isLinux gtk3
++ lib.optionals stdenv.hostPlatform.isDarwin [ Cocoa ];
preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin ''
sed -i 's/set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8")//' ./CMakeLists.txt
'';
installPhase = ''
mkdir -p $out/{include,lib}
mkdir -p $out/lib/pkgconfig
'' + lib.optionalString stdenv.hostPlatform.isLinux ''
mv ./out/libui.so.0 $out/lib/
ln -s $out/lib/libui.so.0 $out/lib/libui.so
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
mv ./out/libui.A.dylib $out/lib/
ln -s $out/lib/libui.A.dylib $out/lib/libui.dylib
'' + ''
cp $src/ui.h $out/include
cp $src/ui_${backend}.h $out/include
cp ${./libui.pc} $out/lib/pkgconfig/libui.pc
substituteInPlace $out/lib/pkgconfig/libui.pc \
--subst-var-by out $out \
--subst-var-by version "${version}"
'';
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
install_name_tool -id $out/lib/libui.A.dylib $out/lib/libui.A.dylib
'';
meta = with lib; {
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";
license = licenses.mit;
platforms = platforms.unix;
};
}