diff options
author | Joachim F <joachifm@users.noreply.github.com> | 2017-08-20 20:33:40 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-20 20:33:40 +0000 |
commit | 61aa254204c83f8a3728547a41390cfd9f5d5771 (patch) | |
tree | f8e428a8b21ea137a34da1e506f3b34f75acbc32 /pkgs/applications/editors | |
parent | 417c1ed4f1a743cbfe8f0d90f2aa80dd328d8c0b (diff) | |
parent | 2a9cb9d36db13a29222cec66802b47a354ccf980 (diff) | |
download | nixlib-61aa254204c83f8a3728547a41390cfd9f5d5771.tar nixlib-61aa254204c83f8a3728547a41390cfd9f5d5771.tar.gz nixlib-61aa254204c83f8a3728547a41390cfd9f5d5771.tar.bz2 nixlib-61aa254204c83f8a3728547a41390cfd9f5d5771.tar.lz nixlib-61aa254204c83f8a3728547a41390cfd9f5d5771.tar.xz nixlib-61aa254204c83f8a3728547a41390cfd9f5d5771.tar.zst nixlib-61aa254204c83f8a3728547a41390cfd9f5d5771.zip |
Merge pull request #28177 from jraygauthier/jrg/vscode-with-extensions
vscode-with-extensions: init at 1.10.2
Diffstat (limited to 'pkgs/applications/editors')
-rw-r--r-- | pkgs/applications/editors/vscode-with-extensions/default.nix | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/pkgs/applications/editors/vscode-with-extensions/default.nix b/pkgs/applications/editors/vscode-with-extensions/default.nix new file mode 100644 index 000000000000..983acbbac197 --- /dev/null +++ b/pkgs/applications/editors/vscode-with-extensions/default.nix @@ -0,0 +1,82 @@ +{ stdenv, lib, fetchurl, runCommand, buildEnv, vscode, which, writeScript +, vscodeExtensions ? [] }: + +/* + `vsixExtensions` + : 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. + vscodeExtensions = with vscodeExtensions; [ + nix + ] + + # Concise version from the vscode market place when not available in the default set. + ++ vscodeUtils.extensionsFromVscodeMarketplace [ + { + name = "code-runner"; + publisher = "formulahendry"; + version = "0.6.33"; + sha256 = "166ia73vrcl5c9hm4q1a73qdn56m0jc7flfsk5p5q41na9f10lb0"; + } + ]; + } + ~~~ + + This expression should fetch + - the *nix* vscode extension from whatever source defined in the + default nixpkgs extensions set `vscodeExtensions`. + + - the *code-runner* vscode extension from the marketplace using the + 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" + ${if [] == vscodeExtensions + then '' + ln -sT "${vscode}/bin/${wrappedExeName}" "$out/bin/${exeName}" + '' + else '' + ln -sT "${wrapperExeFile}" "$out/bin/${exeName}" + ''} +'' |