2017-08-12 06:27:17 +02:00
|
|
|
{ stdenv, lib, fetchurl, runCommand, buildEnv, vscode, which, writeScript
|
|
|
|
, vscodeExtensions ? [] }:
|
|
|
|
|
|
|
|
/*
|
2017-08-24 03:24:57 +02:00
|
|
|
`vscodeExtensions`
|
2017-08-12 06:27:17 +02: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 03:24:57 +02:00
|
|
|
vscodeExtensions = with vscode-extensions; [
|
|
|
|
bbenoist.Nix
|
2018-06-11 00:23:30 +02:00
|
|
|
]
|
2017-08-12 06:27:17 +02:00
|
|
|
|
|
|
|
# Concise version from the vscode market place when not available in the default set.
|
2017-08-24 03:24:57 +02:00
|
|
|
++ vscode-utils.extensionsFromVscodeMarketplace [
|
2017-08-12 06:27:17 +02:00
|
|
|
{
|
|
|
|
name = "code-runner";
|
|
|
|
publisher = "formulahendry";
|
|
|
|
version = "0.6.33";
|
|
|
|
sha256 = "166ia73vrcl5c9hm4q1a73qdn56m0jc7flfsk5p5q41na9f10lb0";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
~~~
|
|
|
|
|
2018-06-11 00:23:30 +02:00
|
|
|
This expression should fetch
|
2017-08-12 06:27:17 +02:00
|
|
|
- the *nix* vscode extension from whatever source defined in the
|
|
|
|
default nixpkgs extensions set `vscodeExtensions`.
|
|
|
|
|
2018-06-11 00:23:30 +02:00
|
|
|
- the *code-runner* vscode extension from the marketplace using the
|
2017-08-12 06:27:17 +02: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
|
|
|
|
|
|
|
|
wrappedPkgVersion = lib.getVersion vscode;
|
|
|
|
wrappedPkgName = lib.removeSuffix "-${wrappedPkgVersion}" vscode.name;
|
|
|
|
|
|
|
|
combinedExtensionsDrv = buildEnv {
|
|
|
|
name = "${wrappedPkgName}-extensions-${wrappedPkgVersion}";
|
|
|
|
paths = vscodeExtensions;
|
|
|
|
};
|
|
|
|
|
|
|
|
wrappedExeName = "code";
|
|
|
|
exeName = wrappedExeName;
|
|
|
|
|
|
|
|
wrapperExeFile = writeScript "${exeName}" ''
|
|
|
|
#!${stdenv.shell}
|
|
|
|
exec ${vscode}/bin/${wrappedExeName} \
|
|
|
|
--extensions-dir "${combinedExtensionsDrv}/share/${wrappedPkgName}/extensions" \
|
|
|
|
"$@"
|
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
# When no extensions are requested, we simply redirect to the original
|
|
|
|
# non-wrapped vscode executable.
|
|
|
|
runCommand "${wrappedPkgName}-with-extensions-${wrappedPkgVersion}" {
|
|
|
|
buildInputs = [ vscode which ];
|
|
|
|
dontPatchELF = true;
|
|
|
|
dontStrip = true;
|
|
|
|
meta = vscode.meta;
|
|
|
|
} ''
|
|
|
|
mkdir -p "$out/bin"
|
2018-06-11 00:23:30 +02:00
|
|
|
mkdir -p "$out/share/applications"
|
|
|
|
mkdir -p "$out/share/pixmaps"
|
|
|
|
|
|
|
|
ln -sT "${vscode}/share/applications/code.desktop" "$out/share/applications/code.desktop"
|
|
|
|
ln -sT "${vscode}/share/pixmaps/code.png" "$out/share/pixmaps/code.png"
|
2017-08-12 06:27:17 +02:00
|
|
|
${if [] == vscodeExtensions
|
|
|
|
then ''
|
|
|
|
ln -sT "${vscode}/bin/${wrappedExeName}" "$out/bin/${exeName}"
|
|
|
|
''
|
|
|
|
else ''
|
|
|
|
ln -sT "${wrapperExeFile}" "$out/bin/${exeName}"
|
|
|
|
''}
|
|
|
|
''
|