2019-10-16 22:09:38 +01:00
|
|
|
{ lib, stdenv, runCommand, buildEnv, vscode, makeWrapper
|
2017-08-12 05:27:17 +01:00
|
|
|
, vscodeExtensions ? [] }:
|
|
|
|
|
|
|
|
/*
|
2017-08-24 02:24:57 +01:00
|
|
|
`vscodeExtensions`
|
2017-08-12 05:27:17 +01:00
|
|
|
: A set of vscode extensions to be installed alongside the editor. Here's a an
|
|
|
|
example:
|
|
|
|
|
|
|
|
~~~
|
|
|
|
vscode-with-extensions.override {
|
|
|
|
|
|
|
|
# When the extension is already available in the default extensions set.
|
2017-08-24 02:24:57 +01:00
|
|
|
vscodeExtensions = with vscode-extensions; [
|
2021-08-14 20:26:44 +01:00
|
|
|
bbenoist.nix
|
2018-06-10 23:23:30 +01:00
|
|
|
]
|
2017-08-12 05:27:17 +01:00
|
|
|
|
|
|
|
# Concise version from the vscode market place when not available in the default set.
|
2017-08-24 02:24:57 +01:00
|
|
|
++ vscode-utils.extensionsFromVscodeMarketplace [
|
2017-08-12 05:27:17 +01:00
|
|
|
{
|
|
|
|
name = "code-runner";
|
|
|
|
publisher = "formulahendry";
|
|
|
|
version = "0.6.33";
|
|
|
|
sha256 = "166ia73vrcl5c9hm4q1a73qdn56m0jc7flfsk5p5q41na9f10lb0";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
~~~
|
|
|
|
|
2018-06-10 23:23:30 +01:00
|
|
|
This expression should fetch
|
2017-08-12 05:27:17 +01:00
|
|
|
- the *nix* vscode extension from whatever source defined in the
|
|
|
|
default nixpkgs extensions set `vscodeExtensions`.
|
|
|
|
|
2018-06-10 23:23:30 +01:00
|
|
|
- the *code-runner* vscode extension from the marketplace using the
|
2017-08-12 05:27:17 +01:00
|
|
|
following url:
|
|
|
|
|
|
|
|
~~~
|
|
|
|
https://bbenoist.gallery.vsassets.io/_apis/public/gallery/publisher/bbenoist/extension/nix/1.0.1/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage
|
|
|
|
~~~
|
|
|
|
|
|
|
|
The original `code` executable will be wrapped so that it uses the set of pre-installed / unpacked
|
|
|
|
extensions as its `--extensions-dir`.
|
|
|
|
*/
|
|
|
|
|
|
|
|
let
|
2019-10-16 22:09:38 +01:00
|
|
|
inherit (vscode) executableName longName;
|
2017-08-12 05:27:17 +01:00
|
|
|
wrappedPkgVersion = lib.getVersion vscode;
|
|
|
|
wrappedPkgName = lib.removeSuffix "-${wrappedPkgVersion}" vscode.name;
|
|
|
|
|
|
|
|
combinedExtensionsDrv = buildEnv {
|
2019-10-16 20:52:31 +01:00
|
|
|
name = "vscode-extensions";
|
2017-08-12 05:27:17 +01:00
|
|
|
paths = vscodeExtensions;
|
|
|
|
};
|
|
|
|
|
2019-10-16 22:09:38 +01:00
|
|
|
extensionsFlag = lib.optionalString (vscodeExtensions != []) ''
|
|
|
|
--add-flags "--extensions-dir ${combinedExtensionsDrv}/share/vscode/extensions"
|
|
|
|
'';
|
2017-08-12 05:27:17 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
# When no extensions are requested, we simply redirect to the original
|
|
|
|
# non-wrapped vscode executable.
|
|
|
|
runCommand "${wrappedPkgName}-with-extensions-${wrappedPkgVersion}" {
|
2021-02-07 09:17:39 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = [ vscode ];
|
2017-08-12 05:27:17 +01:00
|
|
|
dontPatchELF = true;
|
|
|
|
dontStrip = true;
|
|
|
|
meta = vscode.meta;
|
2019-10-16 22:09:38 +01:00
|
|
|
} (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 ''
|
2017-08-12 05:27:17 +01:00
|
|
|
mkdir -p "$out/bin"
|
2018-06-10 23:23:30 +01:00
|
|
|
mkdir -p "$out/share/applications"
|
|
|
|
mkdir -p "$out/share/pixmaps"
|
|
|
|
|
|
|
|
ln -sT "${vscode}/share/pixmaps/code.png" "$out/share/pixmaps/code.png"
|
2018-11-04 01:29:00 +00:00
|
|
|
ln -sT "${vscode}/share/applications/${executableName}.desktop" "$out/share/applications/${executableName}.desktop"
|
2019-06-26 01:12:20 +01:00
|
|
|
ln -sT "${vscode}/share/applications/${executableName}-url-handler.desktop" "$out/share/applications/${executableName}-url-handler.desktop"
|
2019-10-16 22:09:38 +01:00
|
|
|
makeWrapper "${vscode}/bin/${executableName}" "$out/bin/${executableName}" ${extensionsFlag}
|
|
|
|
'')
|