diff options
author | Raymond Gauthier <jraygauthier@gmail.com> | 2017-08-12 00:27:17 -0400 |
---|---|---|
committer | Raymond Gauthier <jraygauthier@gmail.com> | 2017-08-18 11:24:53 -0400 |
commit | 2a9cb9d36db13a29222cec66802b47a354ccf980 (patch) | |
tree | ad1dc2b5b3cc93b229ff786568878773f105bc41 /pkgs/misc | |
parent | 59fa868b01c6f22b9072508cebbecdc4930034e5 (diff) | |
download | nixlib-2a9cb9d36db13a29222cec66802b47a354ccf980.tar nixlib-2a9cb9d36db13a29222cec66802b47a354ccf980.tar.gz nixlib-2a9cb9d36db13a29222cec66802b47a354ccf980.tar.bz2 nixlib-2a9cb9d36db13a29222cec66802b47a354ccf980.tar.lz nixlib-2a9cb9d36db13a29222cec66802b47a354ccf980.tar.xz nixlib-2a9cb9d36db13a29222cec66802b47a354ccf980.tar.zst nixlib-2a9cb9d36db13a29222cec66802b47a354ccf980.zip |
vscode-with-extensions: init at 1.10.2
Diffstat (limited to 'pkgs/misc')
-rw-r--r-- | pkgs/misc/vscode-extensions/default.nix | 18 | ||||
-rw-r--r-- | pkgs/misc/vscode-extensions/vscode-utils.nix | 92 |
2 files changed, 110 insertions, 0 deletions
diff --git a/pkgs/misc/vscode-extensions/default.nix b/pkgs/misc/vscode-extensions/default.nix new file mode 100644 index 000000000000..12900907c00c --- /dev/null +++ b/pkgs/misc/vscode-extensions/default.nix @@ -0,0 +1,18 @@ +{ stdenv, lib, fetchurl, vscode-utils }: + +let + inherit (vscode-utils) buildVscodeExtension buildVscodeMarketplaceExtension; +in + +rec { + nix = buildVscodeMarketplaceExtension { + mktplcRef = { + name = "nix"; + publisher = "bbenoist"; + version = "1.0.1"; + sha256 = "0zd0n9f5z1f0ckzfjr38xw2zzmcxg1gjrava7yahg5cvdcw6l35b"; + }; + + # TODO: Fill meta with appropriate information. + }; +} \ No newline at end of file diff --git a/pkgs/misc/vscode-extensions/vscode-utils.nix b/pkgs/misc/vscode-extensions/vscode-utils.nix new file mode 100644 index 000000000000..759449a745b0 --- /dev/null +++ b/pkgs/misc/vscode-extensions/vscode-utils.nix @@ -0,0 +1,92 @@ +{ stdenv, lib, fetchurl, runCommand, vscode, which }: + +let + extendedPkgVersion = lib.getVersion vscode; + extendedPkgName = lib.removeSuffix "-${extendedPkgVersion}" vscode.name; + + mktplcExtRefToFetchArgs = ext: { + url = "https://${ext.publisher}.gallery.vsassets.io/_apis/public/gallery/publisher/${ext.publisher}/extension/${ext.name}/${ext.version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage"; + sha256 = ext.sha256; + name = "${ext.name}.vsix"; + }; + + buildVscodeExtension = a@{ + name, + namePrefix ? "${extendedPkgName}-extension-", + src, + configurePhase ? ":", + buildPhase ? ":", + dontPatchELF ? true, + dontStrip ? true, + buildInputs ? [], + ... + }: + stdenv.mkDerivation (a // { + + name = namePrefix + name; + + inherit configurePhase buildPhase dontPatchELF dontStrip; + + # TODO: `which` is an encapsulation leak. It should have been hardwired + # as part of the `code` wrapper. + buildInputs = [ vscode which ] ++ buildInputs; + + unpackPhase = '' + # TODO: Unfortunately, 'code' systematically creates its '.vscode' directory + # even tough it has nothing to write in it. We need to redirect this + # to a writeable location as the nix environment already has (but + # to a non writeable one) otherwise the write will fail. + # It would be preferrable if we could intercept / fix this at the source. + HOME="$PWD/code_null_home" code \ + --extensions-dir "$PWD" \ + --install-extension "${toString src}" + + rm -Rf "$PWD/code_null_home" + cd "$(find . -mindepth 1 -type d -print -quit)" + ls -la + ''; + + + installPhase = '' + mkdir -p "$out/share/${extendedPkgName}/extensions/${name}" + find . -mindepth 1 -maxdepth 1 | xargs mv -t "$out/share/${extendedPkgName}/extensions/${name}/" + ''; + + }); + + + fetchVsixFromVscodeMarketplace = mktplcExtRef: + fetchurl((mktplcExtRefToFetchArgs mktplcExtRef)); + + buildVscodeMarketplaceExtension = a@{ + name ? "", + src ? null, + mktplcRef, + ... + }: assert "" == name; assert null == src; + buildVscodeExtension ((removeAttrs a [ "mktplcRef" ]) // { + name = "${mktplcRef.name}-${mktplcRef.version}"; + src = fetchVsixFromVscodeMarketplace mktplcRef; + }); + + mktplcRefAttrList = [ + "name" + "publisher" + "version" + "sha256" + ]; + + mktplcExtRefToExtDrv = ext: + buildVscodeMarketplaceExtension ((removeAttrs ext mktplcRefAttrList) // { + mktplcRef = ext; + }); + + extensionsFromVscodeMarketplace = mktplcExtRefList: + builtins.map mktplcExtRefToExtDrv mktplcExtRefList; + +in + +{ + inherit fetchVsixFromVscodeMarketplace buildVscodeExtension + buildVscodeMarketplaceExtension extensionsFromVscodeMarketplace; +} \ No newline at end of file |