diff --git a/pkgs/by-name/op/opencode-desktop/package.nix b/pkgs/by-name/op/opencode-desktop/package.nix index bfc0cf9c482c..8f2efe9ed76a 100644 --- a/pkgs/by-name/op/opencode-desktop/package.nix +++ b/pkgs/by-name/op/opencode-desktop/package.nix @@ -54,6 +54,12 @@ stdenvNoCC.mkDerivation (finalAttrs: { OPENCODE_CHANNEL = "prod"; MODELS_DEV_API_JSON = "${models-dev}/dist/_api.json"; OPENCODE_DISABLE_MODELS_FETCH = true; + } + # Disable code signing on macOS. Public build hosts don't have Apple Developer + # certificates, so electron-builder's `security find-identity` spawns produce + # EPERM inside the nix sandbox. + // lib.optionalAttrs stdenvNoCC.hostPlatform.isDarwin { + CSC_IDENTITY_AUTO_DISCOVERY = "false"; }; postPatch = '' @@ -73,6 +79,18 @@ stdenvNoCC.mkDerivation (finalAttrs: { runHook postConfigure ''; + preBuild = lib.optionalString stdenvNoCC.hostPlatform.isDarwin '' + # Patch electron-builder to skip code signing on macOS. + # The nix sandbox on public Darwin builders cannot spawn + # `security find-identity` — trying gives spawn EPERM. + # We patch the compiled JS to make getValidIdentities a no-op. + for f in $(find node_modules -path "*/app-builder-lib/out/codeSign/macCodeSign.js" -type f 2>/dev/null); do + substituteInPlace "$f" \ + --replace-fail "async function getValidIdentities" \ + "async function getValidIdentities() { return []; }; async function getValidIdentities_DISABLED" + done + ''; + buildPhase = '' runHook preBuild @@ -98,7 +116,8 @@ stdenvNoCC.mkDerivation (finalAttrs: { --config=electron-builder.config.ts \ --config.electronDist="$HOME/.electron-dist" \ --config.electronVersion=${electron.version} \ - --config.asarUnpack='**/*.node' + --config.asarUnpack='**/*.node' \ + ${lib.optionalString stdenvNoCC.hostPlatform.isDarwin "--config.mac.identity=null"} cd ../..