3
0
Fork 0
forked from mirrors/nixpkgs

vscode: Fix vscode-with-extensions with #70486

This commit is contained in:
Amanda Cameron 2019-10-16 17:09:38 -04:00 committed by Raphael Megzari
parent 247b53f484
commit cf427857a5
2 changed files with 19 additions and 9 deletions

View file

@ -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; };
};

View file

@ -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}
'')