From 96d4beeb6b8c22de1dc290ef85a75e740c5e0876 Mon Sep 17 00:00:00 2001 From: imnyang Date: Tue, 26 May 2026 09:58:10 +0900 Subject: [PATCH] Update vscode-insiders package for improved platform support and permissions handling --- pkgs/vscode-insiders/default.nix | 43 ++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/pkgs/vscode-insiders/default.nix b/pkgs/vscode-insiders/default.nix index 7301371..3dd4d81 100644 --- a/pkgs/vscode-insiders/default.nix +++ b/pkgs/vscode-insiders/default.nix @@ -8,17 +8,20 @@ let if stdenv.hostPlatform.isAarch64 then { url = "https://code.visualstudio.com/sha/download?build=insider&os=darwin-arm64-dmg"; sha256 = "sha256-K+U6JtVNz1PRzL/0SIEK7RXwQu6LL3p+248Ywbn+mDc="; + name = "vscode-insiders-darwin-arm64.dmg"; } else { url = "https://code.visualstudio.com/sha/download?build=insider&os=darwin-x64-dmg"; sha256 = "sha256-ex0ESS9APZxgc7b96Q7EQbckUXE51LmTqDfsnN07W3I="; + name = "vscode-insiders-darwin-x64.dmg"; } else { url = "https://code.visualstudio.com/sha/download?build=insider&os=linux-x64"; sha256 = "sha256-kE99FyilwwFv3zTCkufGwD3s1WwoJ2krg10l3Xy5PRE="; + name = "vscode-insiders-linux-x64.tar.gz"; }; src = fetchurl { - inherit (sysAttrs) url sha256; + inherit (sysAttrs) url sha256 name; }; in @@ -31,6 +34,16 @@ in inherit src; + sourceRoot = lib.optionalString stdenv.hostPlatform.isDarwin "."; + + postUnpack = lib.optionalString stdenv.hostPlatform.isDarwin '' + export sourceRoot="$(ls -d *.app)" + chmod -R +w "$sourceRoot" + ''; + + nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) + ++ lib.optionals stdenv.hostPlatform.isDarwin [ pkgs.undmg pkgs.darwin.xattr ]; + buildInputs = (oldAttrs.buildInputs or []) ++ lib.optionals stdenv.hostPlatform.isLinux [ @@ -39,16 +52,41 @@ in pkgs.webkitgtk_4_1 ]; - prePatch = lib.optionalString stdenv.hostPlatform.isLinux '' + prePatch = if stdenv.hostPlatform.isDarwin then '' + ${oldAttrs.prePatch or ""} + + mkdir -p Contents/Resources/app/node_modules/@vscode/ripgrep/bin + touch Contents/Resources/app/node_modules/@vscode/ripgrep/bin/rg + '' else if stdenv.hostPlatform.isLinux then '' ${oldAttrs.prePatch or ""} mkdir -p resources/app/node_modules/@vscode/ripgrep/bin touch resources/app/node_modules/@vscode/ripgrep/bin/rg + '' else ""; + + installPhase = lib.optionalString stdenv.hostPlatform.isDarwin '' + mkdir -p $out/Applications + cp -r . $out/Applications/Visual\ Studio\ Code\ -\ Insiders.app + + # Create a wrapper script in bin/ to launch the app + mkdir -p $out/bin + cat > $out/bin/code-insiders << 'EOF' + #!/bin/sh + exec "$out/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron" "$@" + EOF + chmod +x $out/bin/code-insiders ''; preFixup = if stdenv.hostPlatform.isDarwin then '' ${oldAttrs.preFixup or ""} + + # Fix executable permissions in the app bundle + chmod +x "Contents/MacOS/Electron" + find Contents -type f -perm +111 -exec chmod +x {} \; + + # Make the app executable for Gatekeeper/notarization checks + xattr -d com.apple.quarantine . 2>/dev/null || true '' else '' ${oldAttrs.preFixup or ""} @@ -57,5 +95,6 @@ in meta = (oldAttrs.meta or {}) // { mainProgram = "code-insiders"; + }; }) \ No newline at end of file