From d92003b5c8762861816a551a30a64d1586403596 Mon Sep 17 00:00:00 2001 From: Qiming Chu Date: Tue, 25 Mar 2025 16:23:31 +0800 Subject: [PATCH] klayout: fix darwin build Signed-off-by: Qiming Chu --- pkgs/applications/misc/klayout/default.nix | 46 +++++++++++++++++----- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/pkgs/applications/misc/klayout/default.nix b/pkgs/applications/misc/klayout/default.nix index 8c045da4e3fd..c7815d0fc81c 100644 --- a/pkgs/applications/misc/klayout/default.nix +++ b/pkgs/applications/misc/klayout/default.nix @@ -1,6 +1,17 @@ -{ lib, mkDerivation, fetchFromGitHub -, python3, ruby, qtbase, qtmultimedia, qttools, qtxmlpatterns -, which, perl, libgit2 +{ + lib, + mkDerivation, + fetchFromGitHub, + python3, + ruby, + qtbase, + qtmultimedia, + qttools, + qtxmlpatterns, + which, + perl, + libgit2, + stdenv, }: mkDerivation rec { @@ -41,12 +52,28 @@ mkDerivation rec { runHook postBuild ''; - postBuild = '' - mkdir $out/bin - mv $out/lib/klayout $out/bin/ + postBuild = + lib.optionalString stdenv.hostPlatform.isLinux '' + mkdir $out/bin - install -Dm444 etc/klayout.desktop -t $out/share/applications - install -Dm444 etc/logo.png $out/share/icons/hicolor/256x256/apps/klayout.png + install -Dm444 etc/klayout.desktop -t $out/share/applications + install -Dm444 etc/logo.png $out/share/icons/hicolor/256x256/apps/klayout.png + mv $out/lib/klayout $out/bin/ + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + mkdir -p $out/Applications + mv $out/lib/klayout.app $out/Applications/ + ''; + + preFixup = lib.optionalString stdenv.hostPlatform.isDarwin '' + exec_name=$out/Applications/klayout.app/Contents/MacOS/klayout + + for lib in $out/lib/libklayout_*.0.dylib; do + base_name=$(basename $lib) + install_name_tool -change "$base_name" "@rpath/$base_name" "$exec_name" + done + + wrapQtApp "$out/Applications/klayout.app/Contents/MacOS/klayout" ''; env.NIX_CFLAGS_COMPILE = toString [ "-Wno-parentheses" ]; @@ -63,8 +90,7 @@ mkDerivation rec { license = with licenses; [ gpl2Plus ]; homepage = "https://www.klayout.de/"; changelog = "https://www.klayout.de/development.html#${version}"; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; maintainers = with maintainers; [ ]; }; } -