From c062264d744cdf38cdc932476d09d74751ed5e7e Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Mon, 24 Feb 2025 16:56:49 +0000 Subject: [PATCH] jetbrains.plugins: fix darwin builds There were 2 issues for usage of `jetbrains.plugins.addPlugins` in darwin: - Some IDE products have spaces in name (e.g.: "IntelliJ IDEA CE"). The current code didn't escape or quoted the strings together, so it failed during build - After fixing the issue above, opening the resulting app bundle (e.g.: `open result/Applications/IntelliJ IDEA CE`) would result in an error because we modified the bundle but kept the old signature This commit fixes both those issues, the first one by quoting the IDE name using `lib.escapeShellArg` and the second one by using `darwin.autoSignDarwinBinariesHook`. --- .../editors/jetbrains/plugins/default.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/editors/jetbrains/plugins/default.nix b/pkgs/applications/editors/jetbrains/plugins/default.nix index 11997430f556..a432a4577521 100644 --- a/pkgs/applications/editors/jetbrains/plugins/default.nix +++ b/pkgs/applications/editors/jetbrains/plugins/default.nix @@ -5,6 +5,7 @@ , callPackage , autoPatchelfHook , glib +, darwin }: let @@ -86,18 +87,24 @@ in { version = ide.version; src = ide; dontInstall = true; - dontFixup = true; + dontStrip = true; passthru.plugins = plugins ++ (ide.plugins or [ ]); newPlugins = plugins; disallowedReferences = [ ide ]; - nativeBuildInputs = (lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook) ++ (ide.nativeBuildInputs or [ ]); + nativeBuildInputs = + (lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook) + # The buildPhase hook rewrites the binary, which invaliates the code + # signature. Add the fixup hook to sign the output. + ++ (lib.optional stdenv.hostPlatform.isDarwin darwin.autoSignDarwinBinariesHook) + ++ (ide.nativeBuildInputs or [ ]); buildInputs = lib.unique ((ide.buildInputs or [ ]) ++ [ glib ]); inherit (ide) meta; buildPhase = let - rootDir = if stdenv.hostPlatform.isDarwin then "Applications/${ide.product}.app/Contents" else meta.mainProgram; + appDir = lib.optionalString stdenv.hostPlatform.isDarwin "Applications/${lib.escapeShellArg ide.product}.app"; + rootDir = if stdenv.hostPlatform.isDarwin then "${appDir}/Contents" else meta.mainProgram; in '' cp -r ${ide} $out