From cf427857a50390b17c382c75a0aa147ec297f48a Mon Sep 17 00:00:00 2001 From: Amanda Cameron Date: Wed, 16 Oct 2019 17:09:38 -0400 Subject: [PATCH] vscode: Fix vscode-with-extensions with #70486 --- pkgs/applications/editors/vscode/generic.nix | 2 +- .../editors/vscode/with-extensions.nix | 26 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/pkgs/applications/editors/vscode/generic.nix b/pkgs/applications/editors/vscode/generic.nix index a7f9fb328ffe..7279d6bf60b5 100644 --- a/pkgs/applications/editors/vscode/generic.nix +++ b/pkgs/applications/editors/vscode/generic.nix @@ -22,7 +22,7 @@ let inherit pname version src sourceRoot; passthru = { - inherit executableName tests updateScript; + inherit executableName longName tests updateScript; fhs = fhs {}; fhsWithPackages = f: fhs { additionalPkgs = f; }; }; diff --git a/pkgs/applications/editors/vscode/with-extensions.nix b/pkgs/applications/editors/vscode/with-extensions.nix index d2c91f155d53..8f4e7f004245 100644 --- a/pkgs/applications/editors/vscode/with-extensions.nix +++ b/pkgs/applications/editors/vscode/with-extensions.nix @@ -1,4 +1,4 @@ -{ lib, runCommand, buildEnv, vscode, makeWrapper +{ lib, stdenv, runCommand, buildEnv, vscode, makeWrapper , vscodeExtensions ? [] }: /* @@ -42,8 +42,7 @@ */ let - - inherit (vscode) executableName; + inherit (vscode) executableName longName; wrappedPkgVersion = lib.getVersion vscode; wrappedPkgName = lib.removeSuffix "-${wrappedPkgVersion}" vscode.name; @@ -52,6 +51,9 @@ let paths = vscodeExtensions; }; + extensionsFlag = lib.optionalString (vscodeExtensions != []) '' + --add-flags "--extensions-dir ${combinedExtensionsDrv}/share/vscode/extensions" + ''; in # When no extensions are requested, we simply redirect to the original @@ -62,7 +64,17 @@ runCommand "${wrappedPkgName}-with-extensions-${wrappedPkgVersion}" { dontPatchELF = true; dontStrip = true; meta = vscode.meta; -} '' +} (if stdenv.isDarwin then '' + mkdir -p $out/bin/ + mkdir -p "$out/Applications/${longName}.app/Contents/MacOS" + + for path in PkgInfo Frameworks Resources _CodeSignature Info.plist; do + ln -s "${vscode}/Applications/${longName}.app/Contents/$path" "$out/Applications/${longName}.app/Contents/" + done + + makeWrapper "${vscode}/bin/${executableName}" "$out/bin/${executableName}" ${extensionsFlag} + makeWrapper "${vscode}/Applications/${longName}.app/Contents/MacOS/Electron" "$out/Applications/${longName}.app/Contents/MacOS/Electron" ${extensionsFlag} +'' else '' mkdir -p "$out/bin" mkdir -p "$out/share/applications" mkdir -p "$out/share/pixmaps" @@ -70,7 +82,5 @@ runCommand "${wrappedPkgName}-with-extensions-${wrappedPkgVersion}" { ln -sT "${vscode}/share/pixmaps/code.png" "$out/share/pixmaps/code.png" ln -sT "${vscode}/share/applications/${executableName}.desktop" "$out/share/applications/${executableName}.desktop" ln -sT "${vscode}/share/applications/${executableName}-url-handler.desktop" "$out/share/applications/${executableName}-url-handler.desktop" - makeWrapper "${vscode}/bin/${executableName}" "$out/bin/${executableName}" ${lib.optionalString (vscodeExtensions != []) '' - --add-flags "--extensions-dir ${combinedExtensionsDrv}/share/vscode/extensions" - ''} -'' + makeWrapper "${vscode}/bin/${executableName}" "$out/bin/${executableName}" ${extensionsFlag} +'')