Merge pull request #308228 from eclairevoyant/vscode-extensions-rfc-166

vscode-extensions.*: format with nixfmt RFC 166 and enforce via CI
This commit is contained in:
superherointj 2024-05-01 10:04:40 -03:00 committed by GitHub
commit e3cd6c03db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
28 changed files with 736 additions and 496 deletions

View File

@ -37,6 +37,7 @@ jobs:
pkgs/development/cuda-modules pkgs/development/cuda-modules
pkgs/test/cuda pkgs/test/cuda
pkgs/top-level/cuda-packages.nix pkgs/top-level/cuda-packages.nix
NIX_FMT_PATHS_VSCODE_EXTS: pkgs/applications/editors/vscode/extensions
# Iterate over all environment variables beginning with NIX_FMT_PATHS_. # Iterate over all environment variables beginning with NIX_FMT_PATHS_.
run: | run: |
for env_var in "${!NIX_FMT_PATHS_@}"; do for env_var in "${!NIX_FMT_PATHS_@}"; do

View File

@ -1,5 +1,4 @@
{ lib { lib, vscode-utils }:
, vscode-utils }:
let let
inherit (vscode-utils) buildVscodeMarketplaceExtension; inherit (vscode-utils) buildVscodeMarketplaceExtension;

View File

@ -1,11 +1,19 @@
{ lib, stdenv, vscode-utils, callPackage }: {
lib,
stdenv,
vscode-utils,
callPackage,
}:
let let
version = "1.50.0"; version = "1.50.0";
rescript-editor-analysis = callPackage ./rescript-editor-analysis.nix { inherit version; }; rescript-editor-analysis = callPackage ./rescript-editor-analysis.nix { inherit version; };
arch = arch =
if stdenv.isLinux then "linux" if stdenv.isLinux then
else if stdenv.isDarwin then "darwin" "linux"
else throw "Unsupported system: ${stdenv.system}"; else if stdenv.isDarwin then
"darwin"
else
throw "Unsupported system: ${stdenv.system}";
analysisDir = "server/analysis_binaries/${arch}"; analysisDir = "server/analysis_binaries/${arch}";
in in
vscode-utils.buildVscodeMarketplaceExtension rec { vscode-utils.buildVscodeMarketplaceExtension rec {
@ -23,7 +31,10 @@ vscode-utils.buildVscodeMarketplaceExtension rec {
meta = { meta = {
description = "The official VSCode plugin for ReScript"; description = "The official VSCode plugin for ReScript";
homepage = "https://github.com/rescript-lang/rescript-vscode"; homepage = "https://github.com/rescript-lang/rescript-vscode";
maintainers = [ lib.maintainers.dlip lib.maintainers.jayesh-bhoot ]; maintainers = [
lib.maintainers.dlip
lib.maintainers.jayesh-bhoot
];
license = lib.licenses.mit; license = lib.licenses.mit;
}; };
} }

View File

@ -1,4 +1,13 @@
{ lib, stdenv, fetchFromGitHub, bash, ocaml, ocamlPackages, dune_3, version }: {
lib,
stdenv,
fetchFromGitHub,
bash,
ocaml,
ocamlPackages,
dune_3,
version,
}:
stdenv.mkDerivation { stdenv.mkDerivation {
pname = "rescript-editor-analysis"; pname = "rescript-editor-analysis";
@ -11,7 +20,11 @@ stdenv.mkDerivation {
hash = "sha256-+Ht8qWwxtFWHFMiV/aoZIs2S3SxkOWgdwSKN+akp/LU="; hash = "sha256-+Ht8qWwxtFWHFMiV/aoZIs2S3SxkOWgdwSKN+akp/LU=";
}; };
nativeBuildInputs = [ ocaml dune_3 ocamlPackages.cppo ]; nativeBuildInputs = [
ocaml
dune_3
ocamlPackages.cppo
];
# Skip testing phases because they need to download and install node modules # Skip testing phases because they need to download and install node modules
postPatch = '' postPatch = ''
@ -28,7 +41,10 @@ stdenv.mkDerivation {
meta = { meta = {
description = "Analysis binary for the ReScript VSCode plugin"; description = "Analysis binary for the ReScript VSCode plugin";
homepage = "https://github.com/rescript-lang/rescript-vscode"; homepage = "https://github.com/rescript-lang/rescript-vscode";
maintainers = [ lib.maintainers.dlip lib.maintainers.jayesh-bhoot ]; maintainers = [
lib.maintainers.dlip
lib.maintainers.jayesh-bhoot
];
license = lib.licenses.mit; license = lib.licenses.mit;
}; };
} }

View File

@ -1,8 +1,9 @@
{ graphviz {
, jre graphviz,
, lib jre,
, makeWrapper lib,
, vscode-utils makeWrapper,
vscode-utils,
}: }:
vscode-utils.buildVscodeMarketplaceExtension rec { vscode-utils.buildVscodeMarketplaceExtension rec {
@ -13,13 +14,9 @@ vscode-utils.buildVscodeMarketplaceExtension rec {
hash = "sha256-TvApcBBI+Egu7t4tJuEYTs6mhvABOY2eXVb57O4gWfs="; hash = "sha256-TvApcBBI+Egu7t4tJuEYTs6mhvABOY2eXVb57O4gWfs=";
}; };
nativeBuildInputs = [ nativeBuildInputs = [ makeWrapper ];
makeWrapper
];
buildInputs = [ buildInputs = [ graphviz ];
graphviz
];
postInstall = '' postInstall = ''
wrapProgram $out/share/vscode/extensions/contextmapper.context-mapper-vscode-extension/lsp/bin/context-mapper-lsp \ wrapProgram $out/share/vscode/extensions/contextmapper.context-mapper-vscode-extension/lsp/bin/context-mapper-lsp \

View File

@ -1,6 +1,4 @@
{ lib { lib, vscode-utils }:
, vscode-utils
}:
vscode-utils.buildVscodeMarketplaceExtension { vscode-utils.buildVscodeMarketplaceExtension {
mktplcRef = { mktplcRef = {

View File

@ -1,4 +1,8 @@
{ lib, vscode-utils, terraform-ls }: {
lib,
vscode-utils,
terraform-ls,
}:
vscode-utils.buildVscodeMarketplaceExtension rec { vscode-utils.buildVscodeMarketplaceExtension rec {
mktplcRef = { mktplcRef = {
name = "terraform"; name = "terraform";

View File

@ -1,4 +1,10 @@
{ lib, vscode-utils, plantuml, jq, moreutils }: {
lib,
vscode-utils,
plantuml,
jq,
moreutils,
}:
vscode-utils.buildVscodeMarketplaceExtension { vscode-utils.buildVscodeMarketplaceExtension {
mktplcRef = { mktplcRef = {
@ -7,7 +13,10 @@ vscode-utils.buildVscodeMarketplaceExtension {
version = "2.17.4"; version = "2.17.4";
hash = "sha256-fnz6ubB73i7rJcv+paYyNV1r4cReuyFPjgPM0HO40ug="; hash = "sha256-fnz6ubB73i7rJcv+paYyNV1r4cReuyFPjgPM0HO40ug=";
}; };
nativeBuildInputs = [ jq moreutils ]; nativeBuildInputs = [
jq
moreutils
];
postInstall = '' postInstall = ''
cd "$out/$installPrefix" cd "$out/$installPrefix"
jq '.contributes.configuration.properties."plantuml.java".default = "${plantuml}/bin/plantuml"' package.json | sponge package.json jq '.contributes.configuration.properties."plantuml.java".default = "${plantuml}/bin/plantuml"' package.json | sponge package.json
@ -15,13 +24,10 @@ vscode-utils.buildVscodeMarketplaceExtension {
meta = { meta = {
description = "A Visual Studio Code extension for supporting Rich PlantUML"; description = "A Visual Studio Code extension for supporting Rich PlantUML";
downloadPage = downloadPage = "https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml";
"https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml";
homepage = "https://github.com/qjebbs/vscode-plantuml"; homepage = "https://github.com/qjebbs/vscode-plantuml";
changelog = changelog = "https://marketplace.visualstudio.com/items/jebbs.plantuml/changelog";
"https://marketplace.visualstudio.com/items/jebbs.plantuml/changelog";
license = lib.licenses.mit; license = lib.licenses.mit;
maintainers = [ lib.maintainers.victormignot ]; maintainers = [ lib.maintainers.victormignot ];
}; };
} }

View File

@ -4,7 +4,12 @@ with vscode-utils;
let let
buildVscodeLanguagePack = { language, version ? "1.76.2023030809", sha256 }: buildVscodeLanguagePack =
{
language,
version ? "1.76.2023030809",
sha256,
}:
buildVscodeMarketplaceExtension { buildVscodeMarketplaceExtension {
mktplcRef = { mktplcRef = {
name = "vscode-language-pack-${language}"; name = "vscode-language-pack-${language}";
@ -15,7 +20,6 @@ let
license = lib.licenses.mit; license = lib.licenses.mit;
}; };
}; };
in in
# See list of core language packs at https://github.com/Microsoft/vscode-loc # See list of core language packs at https://github.com/Microsoft/vscode-loc

View File

@ -1,4 +1,11 @@
{ publisher, name, version, arch ? "", sha256 ? "", hash ? "" }: {
publisher,
name,
version,
arch ? "",
sha256 ? "",
hash ? "",
}:
let let
archurl = (if arch == "" then "" else "?targetPlatform=${arch}"); archurl = (if arch == "" then "" else "?targetPlatform=${arch}");
in in

View File

@ -1,15 +1,17 @@
{ lib {
, icu lib,
, openssl icu,
, patchelf openssl,
, stdenv patchelf,
, vscode-utils stdenv,
vscode-utils,
}: }:
let let
inherit (stdenv.hostPlatform) system; inherit (stdenv.hostPlatform) system;
inherit (vscode-utils) buildVscodeMarketplaceExtension; inherit (vscode-utils) buildVscodeMarketplaceExtension;
extInfo = { extInfo =
{
x86_64-linux = { x86_64-linux = {
arch = "linux-x64"; arch = "linux-x64";
hash = "sha256-7m85Zl9oV40le3nkNPzoKu/AAf8XhQpI8sBMsQXmBg8="; hash = "sha256-7m85Zl9oV40le3nkNPzoKu/AAf8XhQpI8sBMsQXmBg8=";
@ -50,7 +52,8 @@ let
"components/vs-green-server/platforms/darwin-arm64/node_modules/@microsoft/visualstudio-server.darwin-arm64/Microsoft.VisualStudio.Code.Server" "components/vs-green-server/platforms/darwin-arm64/node_modules/@microsoft/visualstudio-server.darwin-arm64/Microsoft.VisualStudio.Code.Server"
]; ];
}; };
}.${system} or (throw "Unsupported system: ${system}"); }
.${system} or (throw "Unsupported system: ${system}");
in in
buildVscodeMarketplaceExtension { buildVscodeMarketplaceExtension {
mktplcRef = { mktplcRef = {
@ -61,19 +64,16 @@ buildVscodeMarketplaceExtension {
}; };
sourceRoot = "extension"; # This has more than one folder. sourceRoot = "extension"; # This has more than one folder.
nativeBuildInputs = [ nativeBuildInputs = [ patchelf ];
patchelf
];
postPatch = '' postPatch =
''
declare ext_unique_id declare ext_unique_id
ext_unique_id="$(basename "$out" | head -c 32)" ext_unique_id="$(basename "$out" | head -c 32)"
patchelf_add_icu_as_needed() { patchelf_add_icu_as_needed() {
declare elf="''${1?}" declare elf="''${1?}"
declare icu_major_v="${ declare icu_major_v="${lib.head (lib.splitVersion (lib.getVersion icu.name))}"
lib.head (lib.splitVersion (lib.getVersion icu.name))
}"
for icu_lib in icui18n icuuc icudata; do for icu_lib in icui18n icuuc icudata; do
patchelf --add-needed "lib''${icu_lib}.so.$icu_major_v" "$elf" patchelf --add-needed "lib''${icu_lib}.so.$icu_major_v" "$elf"
@ -86,7 +86,13 @@ buildVscodeMarketplaceExtension {
patchelf_add_icu_as_needed "$elf" patchelf_add_icu_as_needed "$elf"
patchelf --add-needed "libssl.so" "$elf" patchelf --add-needed "libssl.so" "$elf"
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${lib.makeLibraryPath [stdenv.cc.cc openssl icu.out]}:\$ORIGIN" \ --set-rpath "${
lib.makeLibraryPath [
stdenv.cc.cc
openssl
icu.out
]
}:\$ORIGIN" \
"$elf" "$elf"
} }
@ -95,16 +101,18 @@ buildVscodeMarketplaceExtension {
--replace 't.setExecuteBit=async function(e){if("win32"!==process.platform){const t=i.join(e[a.SERVICEHUB_CONTROLLER_COMPONENT_NAME],"Microsoft.ServiceHub.Controller"),n=i.join(e[a.SERVICEHUB_HOST_COMPONENT_NAME],(0,a.getServiceHubHostEntrypointName)()),r=[(0,a.getServerPath)(e),t,n,(0,c.getReliabilityMonitorPath)(e)];await Promise.all(r.map((e=>(0,o.chmod)(e,"0755"))))}}' 't.setExecuteBit=async function(e){}' --replace 't.setExecuteBit=async function(e){if("win32"!==process.platform){const t=i.join(e[a.SERVICEHUB_CONTROLLER_COMPONENT_NAME],"Microsoft.ServiceHub.Controller"),n=i.join(e[a.SERVICEHUB_HOST_COMPONENT_NAME],(0,a.getServiceHubHostEntrypointName)()),r=[(0,a.getServerPath)(e),t,n,(0,c.getReliabilityMonitorPath)(e)];await Promise.all(r.map((e=>(0,o.chmod)(e,"0755"))))}}' 't.setExecuteBit=async function(e){}'
'' ''
+ (lib.concatStringsSep "\n" (map + (lib.concatStringsSep "\n" (
(bin: '' map (bin: ''
chmod +x "${bin}" chmod +x "${bin}"
'') '') extInfo.binaries
extInfo.binaries)) ))
+ lib.optionalString stdenv.isLinux (lib.concatStringsSep "\n" (map + lib.optionalString stdenv.isLinux (
(bin: '' lib.concatStringsSep "\n" (
map (bin: ''
patchelf_common "${bin}" patchelf_common "${bin}"
'') '') extInfo.binaries
extInfo.binaries)); )
);
meta = { meta = {
changelog = "https://marketplace.visualstudio.com/items/ms-dotnettools.csdevkit/changelog"; changelog = "https://marketplace.visualstudio.com/items/ms-dotnettools.csdevkit/changelog";
@ -112,6 +120,11 @@ buildVscodeMarketplaceExtension {
downloadPage = "https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit"; downloadPage = "https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit";
license = lib.licenses.unfree; license = lib.licenses.unfree;
maintainers = [ lib.maintainers.ggg ]; maintainers = [ lib.maintainers.ggg ];
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; platforms = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
}; };
} }

View File

@ -1,11 +1,11 @@
{ lib {
, vscode-utils lib,
, patchelf vscode-utils,
, icu patchelf,
, stdenv icu,
, openssl stdenv,
, coreutils openssl,
, coreutils,
}: }:
let let
inherit (stdenv.hostPlatform) system; inherit (stdenv.hostPlatform) system;
@ -50,7 +50,8 @@ let
".debugger/arm64/vsdbg" ".debugger/arm64/vsdbg"
]; ];
}; };
}.${system} or (throw "Unsupported system: ${system}"); }
.${system} or (throw "Unsupported system: ${system}");
in in
buildVscodeMarketplaceExtension { buildVscodeMarketplaceExtension {
mktplcRef = { mktplcRef = {
@ -60,16 +61,13 @@ buildVscodeMarketplaceExtension {
inherit (extInfo) hash arch; inherit (extInfo) hash arch;
}; };
nativeBuildInputs = [ nativeBuildInputs = [ patchelf ];
patchelf
];
postPatch = '' postPatch =
''
patchelf_add_icu_as_needed() { patchelf_add_icu_as_needed() {
declare elf="''${1?}" declare elf="''${1?}"
declare icu_major_v="${ declare icu_major_v="${lib.head (lib.splitVersion (lib.getVersion icu.name))}"
lib.head (lib.splitVersion (lib.getVersion icu.name))
}"
for icu_lib in icui18n icuuc icudata; do for icu_lib in icui18n icuuc icudata; do
patchelf --add-needed "lib''${icu_lib}.so.$icu_major_v" "$elf" patchelf --add-needed "lib''${icu_lib}.so.$icu_major_v" "$elf"
@ -82,7 +80,13 @@ buildVscodeMarketplaceExtension {
patchelf_add_icu_as_needed "$elf" patchelf_add_icu_as_needed "$elf"
patchelf --add-needed "libssl.so" "$elf" patchelf --add-needed "libssl.so" "$elf"
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${lib.makeLibraryPath [stdenv.cc.cc openssl icu.out]}:\$ORIGIN" \ --set-rpath "${
lib.makeLibraryPath [
stdenv.cc.cc
openssl
icu.out
]
}:\$ORIGIN" \
"$elf" "$elf"
} }
@ -90,22 +94,29 @@ buildVscodeMarketplaceExtension {
--replace 'uname -m' '${lib.getExe' coreutils "uname"} -m' --replace 'uname -m' '${lib.getExe' coreutils "uname"} -m'
'' ''
+ (lib.concatStringsSep "\n" (map + (lib.concatStringsSep "\n" (
(bin: '' map (bin: ''
chmod +x "${bin}" chmod +x "${bin}"
'') '') extInfo.binaries
extInfo.binaries)) ))
+ lib.optionalString stdenv.isLinux (lib.concatStringsSep "\n" (map + lib.optionalString stdenv.isLinux (
(bin: '' lib.concatStringsSep "\n" (
map (bin: ''
patchelf_common "${bin}" patchelf_common "${bin}"
'') '') extInfo.binaries
extInfo.binaries)); )
);
meta = { meta = {
description = "Official C# support for Visual Studio Code"; description = "Official C# support for Visual Studio Code";
homepage = "https://github.com/dotnet/vscode-csharp"; homepage = "https://github.com/dotnet/vscode-csharp";
license = lib.licenses.mit; license = lib.licenses.mit;
maintainers = with lib.maintainers; [ ggg ]; maintainers = with lib.maintainers; [ ggg ];
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; platforms = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
}; };
} }

View File

@ -1,19 +1,20 @@
{ lib {
, vscode-utils lib,
, icu vscode-utils,
, python3 icu,
python3,
# When `true`, the python default setting will be fixed to specified. # When `true`, the python default setting will be fixed to specified.
# Use version from `PATH` for default setting otherwise. # Use version from `PATH` for default setting otherwise.
# Defaults to `false` as we expect it to be project specific most of the time. # Defaults to `false` as we expect it to be project specific most of the time.
, pythonUseFixed ? false pythonUseFixed ? false,
# For updateScript # For updateScript
, writeScript writeScript,
, bash bash,
, curl curl,
, coreutils coreutils,
, gnused gnused,
, jq jq,
, nix nix,
}: }:
vscode-utils.buildVscodeMarketplaceExtension rec { vscode-utils.buildVscodeMarketplaceExtension rec {
@ -33,7 +34,8 @@ vscode-utils.buildVscodeMarketplaceExtension rec {
jedi-language-server jedi-language-server
]; ];
postPatch = '' postPatch =
''
# remove bundled python deps and use libs from nixpkgs # remove bundled python deps and use libs from nixpkgs
rm -r pythonFiles/lib rm -r pythonFiles/lib
mkdir -p pythonFiles/lib/python/ mkdir -p pythonFiles/lib/python/
@ -42,7 +44,8 @@ vscode-utils.buildVscodeMarketplaceExtension rec {
for i in pythonFiles/*.py; do for i in pythonFiles/*.py; do
patchPythonScript "$i" patchPythonScript "$i"
done done
'' + lib.optionalString pythonUseFixed '' ''
+ lib.optionalString pythonUseFixed ''
# Patch `packages.json` so that nix's *python* is used as default value for `python.pythonPath`. # Patch `packages.json` so that nix's *python* is used as default value for `python.pythonPath`.
substituteInPlace "./package.json" \ substituteInPlace "./package.json" \
--replace "\"default\": \"python\"" "\"default\": \"${python3.interpreter}\"" --replace "\"default\": \"python\"" "\"default\": \"${python3.interpreter}\""
@ -53,13 +56,15 @@ vscode-utils.buildVscodeMarketplaceExtension rec {
set -eu -o pipefail set -eu -o pipefail
export PATH=${lib.makeBinPath [ export PATH=${
lib.makeBinPath [
curl curl
coreutils coreutils
gnused gnused
jq jq
nix nix
]} ]
}
api=$(curl -s 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery' \ api=$(curl -s 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery' \
-H 'accept: application/json;api-version=3.0-preview.1' \ -H 'accept: application/json;api-version=3.0-preview.1' \
@ -82,7 +87,14 @@ vscode-utils.buildVscodeMarketplaceExtension rec {
homepage = "https://github.com/Microsoft/vscode-python"; homepage = "https://github.com/Microsoft/vscode-python";
changelog = "https://github.com/microsoft/vscode-python/releases"; changelog = "https://github.com/microsoft/vscode-python/releases";
license = lib.licenses.mit; license = lib.licenses.mit;
platforms = [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ]; platforms = [
maintainers = [ lib.maintainers.jraygauthier lib.maintainers.jfchevrette ]; "x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
maintainers = [
lib.maintainers.jraygauthier
lib.maintainers.jfchevrette
];
}; };
} }

View File

@ -1,4 +1,9 @@
{ lib, vscode-utils, jq, moreutils }: {
lib,
vscode-utils,
jq,
moreutils,
}:
vscode-utils.buildVscodeMarketplaceExtension { vscode-utils.buildVscodeMarketplaceExtension {
mktplcRef = { mktplcRef = {

View File

@ -1,7 +1,8 @@
{ lib {
, nixosTests lib,
, vscode-utils nixosTests,
, useLocalExtensions ? false vscode-utils,
useLocalExtensions ? false,
}: }:
# Note that useLocalExtensions requires that vscode-server is not running # Note that useLocalExtensions requires that vscode-server is not running
# on host. If it is, you'll need to remove $HOME/.vscode-server, # on host. If it is, you'll need to remove $HOME/.vscode-server,
@ -92,7 +93,9 @@ buildVscodeMarketplaceExtension {
--replace '# Start the server\n' '${patch}' --replace '# Start the server\n' '${patch}'
''; '';
passthru.tests = { inherit (nixosTests) vscode-remote-ssh; }; passthru.tests = {
inherit (nixosTests) vscode-remote-ssh;
};
meta = { meta = {
description = "Use any remote machine with a SSH server as your development environment."; description = "Use any remote machine with a SSH server as your development environment.";

View File

@ -1,8 +1,19 @@
{ lib, vscode-utils {
, fetchurl, writeScript, runtimeShell lib,
, jq, clang-tools vscode-utils,
, gdbUseFixed ? true, gdb # The gdb default setting will be fixed to specified. Use version from `PATH` otherwise. fetchurl,
, autoPatchelfHook, makeWrapper, stdenv, lttng-ust, libkrb5, zlib writeScript,
runtimeShell,
jq,
clang-tools,
gdbUseFixed ? true,
gdb, # The gdb default setting will be fixed to specified. Use version from `PATH` otherwise.
autoPatchelfHook,
makeWrapper,
stdenv,
lttng-ust,
libkrb5,
zlib,
}: }:
/* /*
@ -94,7 +105,13 @@ vscode-utils.buildVscodeMarketplaceExtension {
description = "The C/C++ extension adds language support for C/C++ to Visual Studio Code, including features such as IntelliSense and debugging."; description = "The C/C++ extension adds language support for C/C++ to Visual Studio Code, including features such as IntelliSense and debugging.";
homepage = "https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools"; homepage = "https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools";
license = lib.licenses.unfree; license = lib.licenses.unfree;
maintainers = [ lib.maintainers.jraygauthier lib.maintainers.stargate01 ]; maintainers = [
platforms = [ "x86_64-linux" "aarch64-linux" ]; lib.maintainers.jraygauthier
lib.maintainers.stargate01
];
platforms = [
"x86_64-linux"
"aarch64-linux"
];
}; };
} }

View File

@ -1,4 +1,8 @@
{ lib, vscode-utils, xsel }: {
lib,
vscode-utils,
xsel,
}:
vscode-utils.buildVscodeMarketplaceExtension { vscode-utils.buildVscodeMarketplaceExtension {
mktplcRef = { mktplcRef = {

View File

@ -1,16 +1,17 @@
{ lib {
, fetchFromGitHub lib,
, vscode-utils fetchFromGitHub,
, jq vscode-utils,
, rust-analyzer jq,
, nodePackages rust-analyzer,
, moreutils nodePackages,
, esbuild moreutils,
, pkg-config esbuild,
, libsecret pkg-config,
, stdenv libsecret,
, darwin stdenv,
, setDefaultServerPath ? true darwin,
setDefaultServerPath ? true,
}: }:
let let
@ -29,23 +30,29 @@ let
hash = "sha256-Oj/RPMridKpYt3eRqUIPg9YNrj6npG8THIGuWjsamnE="; hash = "sha256-Oj/RPMridKpYt3eRqUIPg9YNrj6npG8THIGuWjsamnE=";
}; };
build-deps = nodePackages."rust-analyzer-build-deps-../../applications/editors/vscode/extensions/rust-lang.rust-analyzer/build-deps"; build-deps =
nodePackages."rust-analyzer-build-deps-../../applications/editors/vscode/extensions/rust-lang.rust-analyzer/build-deps";
# FIXME: Making a new derivation to link `node_modules` and run `npm run package` # FIXME: Making a new derivation to link `node_modules` and run `npm run package`
# will cause a build failure. # will cause a build failure.
vsix = build-deps.override { vsix = build-deps.override {
src = "${src}/editors/code"; src = "${src}/editors/code";
outputs = [ "vsix" "out" ]; outputs = [
"vsix"
"out"
];
inherit releaseTag; inherit releaseTag;
nativeBuildInputs = [ nativeBuildInputs =
[
jq jq
moreutils moreutils
esbuild esbuild
# Required by `keytar`, which is a dependency of `vsce`. # Required by `keytar`, which is a dependency of `vsce`.
pkg-config pkg-config
libsecret libsecret
] ++ lib.optionals stdenv.isDarwin [ ]
++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.AppKit darwin.apple_sdk.frameworks.AppKit
darwin.apple_sdk.frameworks.Security darwin.apple_sdk.frameworks.Security
]; ];
@ -65,7 +72,6 @@ let
echo y | npx vsce package -o $vsix/${pname}.zip echo y | npx vsce package -o $vsix/${pname}.zip
''; '';
}; };
in in
vscode-utils.buildVscodeExtension { vscode-utils.buildVscodeExtension {
inherit version vsix; inherit version vsix;
@ -75,7 +81,10 @@ vscode-utils.buildVscodeExtension {
vscodeExtPublisher = publisher; vscodeExtPublisher = publisher;
vscodeExtName = pname; vscodeExtName = pname;
nativeBuildInputs = lib.optionals setDefaultServerPath [ jq moreutils ]; nativeBuildInputs = lib.optionals setDefaultServerPath [
jq
moreutils
];
preInstall = lib.optionalString setDefaultServerPath '' preInstall = lib.optionalString setDefaultServerPath ''
jq '.contributes.configuration.properties."rust-analyzer.server.path".default = $s' \ jq '.contributes.configuration.properties."rust-analyzer.server.path".default = $s' \
@ -86,9 +95,11 @@ vscode-utils.buildVscodeExtension {
meta = { meta = {
description = "An alternative rust language server to the RLS"; description = "An alternative rust language server to the RLS";
homepage = "https://github.com/rust-lang/rust-analyzer"; homepage = "https://github.com/rust-lang/rust-analyzer";
license = [ lib.licenses.mit lib.licenses.asl20 ]; license = [
lib.licenses.mit
lib.licenses.asl20
];
maintainers = [ ]; maintainers = [ ];
platforms = lib.platforms.all; platforms = lib.platforms.all;
}; };
} }

View File

@ -1,6 +1,7 @@
{ lib {
, vscode-utils lib,
, lua-language-server vscode-utils,
lua-language-server,
}: }:
vscode-utils.buildVscodeMarketplaceExtension { vscode-utils.buildVscodeMarketplaceExtension {

View File

@ -1,16 +1,18 @@
# Updates the vscode setting file base on a nix expression # Updates the vscode setting file base on a nix expression
# should run from the workspace root. # should run from the workspace root.
{ writeShellScriptBin {
, lib writeShellScriptBin,
, jq lib,
jq,
}: }:
##User Input ##User Input
{ settings ? {} {
settings ? { },
# if marked as true will create an empty json file if does not exist # if marked as true will create an empty json file if does not exist
, createIfDoesNotExists ? true createIfDoesNotExists ? true,
, vscodeSettingsFile ? ".vscode/settings.json" vscodeSettingsFile ? ".vscode/settings.json",
, userSettingsFolder ? "" userSettingsFolder ? "",
, symlinkFromUserSetting ? false symlinkFromUserSetting ? false,
}: }:
let let
@ -23,17 +25,19 @@ let
createEmptySettingsCmd = ''mkdir -p .vscode && echo "{}" > ${vscodeSettingsFile}''; createEmptySettingsCmd = ''mkdir -p .vscode && echo "{}" > ${vscodeSettingsFile}'';
fileName = builtins.baseNameOf vscodeSettingsFile; fileName = builtins.baseNameOf vscodeSettingsFile;
symlinkFromUserSettingCmd = lib.optionalString symlinkFromUserSetting symlinkFromUserSettingCmd = lib.optionalString symlinkFromUserSetting ''&& mkdir -p "${userSettingsFolder}" && ln -sfv "$(pwd)/${vscodeSettingsFile}" "${userSettingsFolder}/" '';
'' && mkdir -p "${userSettingsFolder}" && ln -sfv "$(pwd)/${vscodeSettingsFile}" "${userSettingsFolder}/" '';
in in
writeShellScriptBin ''vscodeNixUpdate-${lib.removeSuffix ".json" (fileName)}'' writeShellScriptBin ''vscodeNixUpdate-${lib.removeSuffix ".json" (fileName)}'' (
(lib.optionalString (settings != {}) lib.optionalString (settings != { }) (
(if createIfDoesNotExists then '' if createIfDoesNotExists then
''
[ ! -f "${vscodeSettingsFile}" ] && ${createEmptySettingsCmd} [ ! -f "${vscodeSettingsFile}" ] && ${createEmptySettingsCmd}
${updateVSCodeSettingsCmd} ${symlinkFromUserSettingCmd} ${updateVSCodeSettingsCmd} ${symlinkFromUserSettingCmd}
'' ''
else ''[ -f "${vscodeSettingsFile}" ] && ${updateVSCodeSettingsCmd} ${symlinkFromUserSettingCmd} else
''
[ -f "${vscodeSettingsFile}" ] && ${updateVSCodeSettingsCmd} ${symlinkFromUserSettingCmd}
'' ''
) )
) )

View File

@ -1,5 +1,20 @@
{ pkgs, lib, stdenv, fetchFromGitHub, runCommand, rustPlatform, makeWrapper, llvmPackages {
, buildNpmPackage, cmake, nodejs, unzip, python3, pkg-config, libsecret, darwin pkgs,
lib,
stdenv,
fetchFromGitHub,
runCommand,
rustPlatform,
makeWrapper,
llvmPackages,
buildNpmPackage,
cmake,
nodejs,
unzip,
python3,
pkg-config,
libsecret,
darwin,
}: }:
assert lib.versionAtLeast python3.version "3.5"; assert lib.versionAtLeast python3.version "3.5";
let let
@ -31,9 +46,7 @@ let
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper ];
env = lib.optionalAttrs stdenv.isDarwin { env = lib.optionalAttrs stdenv.isDarwin { NIX_LDFLAGS = "-llldb -lc++abi"; };
NIX_LDFLAGS = "-llldb -lc++abi";
};
buildAndTestSubdir = "adapter"; buildAndTestSubdir = "adapter";
@ -76,12 +89,15 @@ let
pkg-config pkg-config
]; ];
buildInputs = [ buildInputs =
libsecret [ libsecret ]
] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ ++ lib.optionals stdenv.isDarwin (
with darwin.apple_sdk.frameworks;
[
Security Security
AppKit AppKit
]); ]
);
dontNpmBuild = true; dontNpmBuild = true;
@ -103,14 +119,25 @@ let
"/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver" "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver"
else else
"${lldb.out}/bin/lldb-server"; "${lldb.out}/bin/lldb-server";
in
in stdenv.mkDerivation { stdenv.mkDerivation {
pname = "vscode-extension-${publisher}-${pname}"; pname = "vscode-extension-${publisher}-${pname}";
inherit src version vscodeExtUniqueId vscodeExtPublisher vscodeExtName; inherit
src
version
vscodeExtUniqueId
vscodeExtPublisher
vscodeExtName
;
installPrefix = "share/vscode/extensions/${vscodeExtUniqueId}"; installPrefix = "share/vscode/extensions/${vscodeExtUniqueId}";
nativeBuildInputs = [ cmake nodejs unzip makeWrapper ]; nativeBuildInputs = [
cmake
nodejs
unzip
makeWrapper
];
patches = [ ./cmake-build-extension-only.patch ]; patches = [ ./cmake-build-extension-only.patch ];
@ -120,9 +147,11 @@ in stdenv.mkDerivation {
--replace "1.9.2" ${version} --replace "1.9.2" ${version}
''; '';
postConfigure = '' postConfigure =
''
cp -r ${nodeDeps}/lib/node_modules . cp -r ${nodeDeps}/lib/node_modules .
'' + lib.optionalString stdenv.isDarwin '' ''
+ lib.optionalString stdenv.isDarwin ''
export HOME="$TMPDIR/home" export HOME="$TMPDIR/home"
mkdir $HOME mkdir $HOME
''; '';

View File

@ -1,5 +1,9 @@
# Patched lldb for Rust language support. # Patched lldb for Rust language support.
{ fetchFromGitHub, runCommand, llvmPackages }: {
fetchFromGitHub,
runCommand,
llvmPackages,
}:
let let
llvmSrc = fetchFromGitHub { llvmSrc = fetchFromGitHub {
owner = "vadimcn"; owner = "vadimcn";
@ -8,7 +12,8 @@ let
rev = "4c267c83cbb55fedf2e0b89644dc1db320fdfde7"; rev = "4c267c83cbb55fedf2e0b89644dc1db320fdfde7";
hash = "sha256-jM//ej6AxnRYj+8BAn4QrxHPT6HiDzK5RqHPSg3dCcw="; hash = "sha256-jM//ej6AxnRYj+8BAn4QrxHPT6HiDzK5RqHPSg3dCcw=";
}; };
in (llvmPackages.lldb.overrideAttrs (oldAttrs: rec { in
(llvmPackages.lldb.overrideAttrs (oldAttrs: rec {
passthru = (oldAttrs.passthru or { }) // { passthru = (oldAttrs.passthru or { }) // {
inherit llvmSrc; inherit llvmSrc;
}; };
@ -23,7 +28,8 @@ in (llvmPackages.lldb.overrideAttrs (oldAttrs: rec {
echo "'lldb --version' returns: $versionOutput" echo "'lldb --version' returns: $versionOutput"
echo "$versionOutput" | grep -q 'rust-enabled' echo "$versionOutput" | grep -q 'rust-enabled'
''; '';
})).override({ })).override
({
monorepoSrc = llvmSrc; monorepoSrc = llvmSrc;
libllvm = llvmPackages.libllvm.override ({ monorepoSrc = llvmSrc; }); libllvm = llvmPackages.libllvm.override ({ monorepoSrc = llvmSrc; });
}) })

View File

@ -1,6 +1,16 @@
{ stdenv, lib, buildEnv, writeShellScriptBin, fetchurl, vscode, unzip, jq }: {
stdenv,
lib,
buildEnv,
writeShellScriptBin,
fetchurl,
vscode,
unzip,
jq,
}:
let let
buildVscodeExtension = a@{ buildVscodeExtension =
a@{
name, name,
src, src,
# Same as "Unique Identifier" on the extension's web page. # Same as "Unique Identifier" on the extension's web page.
@ -22,7 +32,9 @@ let
passthru ? { }, passthru ? { },
... ...
}: }:
stdenv.mkDerivation ((removeAttrs a [ "vscodeExtUniqueId" ]) // { stdenv.mkDerivation (
(removeAttrs a [ "vscodeExtUniqueId" ])
// {
name = "vscode-extension-${name}"; name = "vscode-extension-${name}";
@ -30,7 +42,12 @@ let
inherit vscodeExtPublisher vscodeExtName vscodeExtUniqueId; inherit vscodeExtPublisher vscodeExtName vscodeExtUniqueId;
}; };
inherit configurePhase buildPhase dontPatchELF dontStrip; inherit
configurePhase
buildPhase
dontPatchELF
dontStrip
;
# Some .vsix files contain other directories (e.g., `package`) that we don't use. # Some .vsix files contain other directories (e.g., `package`) that we don't use.
# If other directories are present but `sourceRoot` is unset, the unpacker phase fails. # If other directories are present but `sourceRoot` is unset, the unpacker phase fails.
@ -49,29 +66,36 @@ let
runHook postInstall runHook postInstall
''; '';
}
);
}); fetchVsixFromVscodeMarketplace =
mktplcExtRef: fetchurl (import ./mktplcExtRefToFetchArgs.nix mktplcExtRef);
fetchVsixFromVscodeMarketplace = mktplcExtRef: buildVscodeMarketplaceExtension =
fetchurl (import ./mktplcExtRefToFetchArgs.nix mktplcExtRef); a@{
buildVscodeMarketplaceExtension = a@{
name ? "", name ? "",
src ? null, src ? null,
vsix ? null, vsix ? null,
mktplcRef, mktplcRef,
... ...
}: assert "" == name; assert null == src; }:
buildVscodeExtension ((removeAttrs a [ "mktplcRef" "vsix" ]) // { assert "" == name;
assert null == src;
buildVscodeExtension (
(removeAttrs a [
"mktplcRef"
"vsix"
])
// {
name = "${mktplcRef.publisher}-${mktplcRef.name}-${mktplcRef.version}"; name = "${mktplcRef.publisher}-${mktplcRef.name}-${mktplcRef.version}";
version = mktplcRef.version; version = mktplcRef.version;
src = if (vsix != null) src = if (vsix != null) then vsix else fetchVsixFromVscodeMarketplace mktplcRef;
then vsix
else fetchVsixFromVscodeMarketplace mktplcRef;
vscodeExtPublisher = mktplcRef.publisher; vscodeExtPublisher = mktplcRef.publisher;
vscodeExtName = mktplcRef.name; vscodeExtName = mktplcRef.name;
vscodeExtUniqueId = "${mktplcRef.publisher}.${mktplcRef.name}"; vscodeExtUniqueId = "${mktplcRef.publisher}.${mktplcRef.name}";
}); }
);
mktplcRefAttrList = [ mktplcRefAttrList = [
"name" "name"
@ -82,14 +106,18 @@ let
"arch" "arch"
]; ];
mktplcExtRefToExtDrv = ext: mktplcExtRefToExtDrv =
buildVscodeMarketplaceExtension (removeAttrs ext mktplcRefAttrList // { ext:
buildVscodeMarketplaceExtension (
removeAttrs ext mktplcRefAttrList
// {
mktplcRef = builtins.intersectAttrs (lib.genAttrs mktplcRefAttrList (_: null)) ext; mktplcRef = builtins.intersectAttrs (lib.genAttrs mktplcRefAttrList (_: null)) ext;
}); }
);
extensionFromVscodeMarketplace = mktplcExtRefToExtDrv; extensionFromVscodeMarketplace = mktplcExtRefToExtDrv;
extensionsFromVscodeMarketplace = mktplcExtRefList: extensionsFromVscodeMarketplace =
builtins.map extensionFromVscodeMarketplace mktplcExtRefList; mktplcExtRefList: builtins.map extensionFromVscodeMarketplace mktplcExtRefList;
vscodeWithConfiguration = import ./vscodeWithConfiguration.nix { vscodeWithConfiguration = import ./vscodeWithConfiguration.nix {
inherit lib extensionsFromVscodeMarketplace writeShellScriptBin; inherit lib extensionsFromVscodeMarketplace writeShellScriptBin;
@ -102,7 +130,13 @@ let
}; };
vscodeEnv = import ./vscodeEnv.nix { vscodeEnv = import ./vscodeEnv.nix {
inherit lib buildEnv writeShellScriptBin extensionsFromVscodeMarketplace jq; inherit
lib
buildEnv
writeShellScriptBin
extensionsFromVscodeMarketplace
jq
;
vscodeDefault = vscode; vscodeDefault = vscode;
}; };
@ -139,9 +173,16 @@ let
toExtensionJson = extensions: builtins.toJSON (map toExtensionJsonEntry extensions); toExtensionJson = extensions: builtins.toJSON (map toExtensionJsonEntry extensions);
in in
{ {
inherit fetchVsixFromVscodeMarketplace buildVscodeExtension inherit
buildVscodeMarketplaceExtension extensionFromVscodeMarketplace fetchVsixFromVscodeMarketplace
buildVscodeExtension
buildVscodeMarketplaceExtension
extensionFromVscodeMarketplace
extensionsFromVscodeMarketplace extensionsFromVscodeMarketplace
vscodeWithConfiguration vscodeExts2nix vscodeEnv vscodeWithConfiguration
toExtensionJsonEntry toExtensionJson; vscodeExts2nix
vscodeEnv
toExtensionJsonEntry
toExtensionJson
;
} }

View File

@ -1,37 +1,48 @@
#Use vscodeWithConfiguration and vscodeExts2nix to create a vscode executable. When the executable exits, it updates the mutable extension file, which is imported when evaluated by Nix later. #Use vscodeWithConfiguration and vscodeExts2nix to create a vscode executable. When the executable exits, it updates the mutable extension file, which is imported when evaluated by Nix later.
{ lib {
, buildEnv lib,
, writeShellScriptBin buildEnv,
, extensionsFromVscodeMarketplace writeShellScriptBin,
, vscodeDefault extensionsFromVscodeMarketplace,
, jq vscodeDefault,
jq,
}: }:
##User input ##User input
{ vscode ? vscodeDefault {
, nixExtensions ? [] vscode ? vscodeDefault,
, vscodeExtsFolderName ? ".vscode-exts" nixExtensions ? [ ],
vscodeExtsFolderName ? ".vscode-exts",
# will add to the command updateSettings (which will run on executing vscode) settings to override in settings.json file # will add to the command updateSettings (which will run on executing vscode) settings to override in settings.json file
, settings ? {} settings ? { },
, createSettingsIfDoesNotExists ? true createSettingsIfDoesNotExists ? true,
, launch ? {} launch ? { },
, createLaunchIfDoesNotExists ? true createLaunchIfDoesNotExists ? true,
# will add to the command updateKeybindings(which will run on executing vscode) keybindings to override in keybinding.json file # will add to the command updateKeybindings(which will run on executing vscode) keybindings to override in keybinding.json file
, keybindings ? {} keybindings ? { },
, createKeybindingsIfDoesNotExists ? true createKeybindingsIfDoesNotExists ? true,
, user-data-dir ? ''"''${TMP}''${name}"/vscode-data-dir'' user-data-dir ? ''"''${TMP}''${name}"/vscode-data-dir'',
# if file exists will use it and import the extensions in it into this derivation else will use empty extensions list # if file exists will use it and import the extensions in it into this derivation else will use empty extensions list
# this file will be created/updated by vscodeExts2nix when vscode exists # this file will be created/updated by vscodeExts2nix when vscode exists
, mutableExtensionsFile mutableExtensionsFile,
}: }:
let let
mutableExtensionsFilePath = toString mutableExtensionsFile; mutableExtensionsFilePath = toString mutableExtensionsFile;
mutableExtensions = lib.optionals (builtins.pathExists mutableExtensionsFile) (import mutableExtensionsFilePath); mutableExtensions = lib.optionals (builtins.pathExists mutableExtensionsFile) (
vscodeWithConfiguration = import ./vscodeWithConfiguration.nix { import mutableExtensionsFilePath
);
vscodeWithConfiguration =
import ./vscodeWithConfiguration.nix
{
inherit lib writeShellScriptBin extensionsFromVscodeMarketplace; inherit lib writeShellScriptBin extensionsFromVscodeMarketplace;
vscodeDefault = vscode; vscodeDefault = vscode;
} }
{ {
inherit nixExtensions mutableExtensions vscodeExtsFolderName user-data-dir; inherit
nixExtensions
mutableExtensions
vscodeExtsFolderName
user-data-dir
;
}; };
updateSettings = import ./updateSettings.nix { inherit lib writeShellScriptBin jq; }; updateSettings = import ./updateSettings.nix { inherit lib writeShellScriptBin jq; };
@ -62,7 +73,9 @@ let
symlinkFromUserSetting = (user-data-dir != ""); symlinkFromUserSetting = (user-data-dir != "");
}; };
vscodeExts2nix = import ./vscodeExts2nix.nix { vscodeExts2nix =
import ./vscodeExts2nix.nix
{
inherit lib writeShellScriptBin; inherit lib writeShellScriptBin;
vscodeDefault = vscodeWithConfiguration; vscodeDefault = vscodeWithConfiguration;
} }
@ -81,5 +94,11 @@ let
in in
buildEnv { buildEnv {
name = "vscodeEnv"; name = "vscodeEnv";
paths = [ code vscodeExts2nix updateSettingsCmd updateLaunchCmd updateKeybindingsCmd ]; paths = [
code
vscodeExts2nix
updateSettingsCmd
updateLaunchCmd
updateKeybindingsCmd
];
} }

View File

@ -1,8 +1,10 @@
with import <nixpkgs> { }; with import <nixpkgs> { };
callPackage (import ./vscodeEnv.nix) { callPackage (import ./vscodeEnv.nix)
{
extensionsFromVscodeMarketplace = vscode-utils.extensionsFromVscodeMarketplace; extensionsFromVscodeMarketplace = vscode-utils.extensionsFromVscodeMarketplace;
vscodeDefault = vscode; vscodeDefault = vscode;
} { }
{
mutableExtensionsFile = ./extensions.nix; mutableExtensionsFile = ./extensions.nix;
settings = { settings = {
a = "fdsdf"; a = "fdsdf";

View File

@ -1,14 +1,16 @@
# based on the passed vscode will stdout a nix expression with the installed vscode extensions # based on the passed vscode will stdout a nix expression with the installed vscode extensions
{ lib {
, vscodeDefault lib,
, writeShellScriptBin vscodeDefault,
writeShellScriptBin,
}: }:
##User input ##User input
{ vscode ? vscodeDefault {
, extensionsToIgnore ? [] vscode ? vscodeDefault,
extensionsToIgnore ? [ ],
# will use those extensions to get sha256 if still exists when executed. # will use those extensions to get sha256 if still exists when executed.
, extensions ? [] extensions ? [ ],
}: }:
let let
mktplcExtRefToFetchArgs = import ./mktplcExtRefToFetchArgs.nix; mktplcExtRefToFetchArgs = import ./mktplcExtRefToFetchArgs.nix;
@ -17,9 +19,13 @@ writeShellScriptBin "vscodeExts2nix" ''
echo '[' echo '['
for line in $(${vscode}/bin/code --list-extensions --show-versions \ for line in $(${vscode}/bin/code --list-extensions --show-versions \
${lib.optionalString (extensionsToIgnore != []) '' ${
| grep -v -i '^\(${lib.concatMapStringsSep "\\|" (e : "${e.publisher}.${e.name}") extensionsToIgnore}\)' lib.optionalString (extensionsToIgnore != [ ]) ''
''} | grep -v -i '^\(${
lib.concatMapStringsSep "\\|" (e: "${e.publisher}.${e.name}") extensionsToIgnore
}\)'
''
}
) ; do ) ; do
[[ $line =~ ([^.]*)\.([^@]*)@(.*) ]] [[ $line =~ ([^.]*)\.([^@]*)@(.*) ]]
name=''${BASH_REMATCH[2]} name=''${BASH_REMATCH[2]}
@ -32,7 +38,13 @@ writeShellScriptBin "vscodeExts2nix" ''
sha256=''${BASH_REMATCH[1]} sha256=''${BASH_REMATCH[1]}
else else
sha256=$( sha256=$(
nix-prefetch-url "${(mktplcExtRefToFetchArgs {publisher = ''"$publisher"''; name = ''"$name"''; version = ''"$version"'';}).url}" 2> /dev/null nix-prefetch-url "${
(mktplcExtRefToFetchArgs {
publisher = ''"$publisher"'';
name = ''"$name"'';
version = ''"$version"'';
}).url
}" 2> /dev/null
) )
fi fi

View File

@ -1,39 +1,46 @@
# wrapper over vscode to control extensions per project (extensions folder will be created in execution path) # wrapper over vscode to control extensions per project (extensions folder will be created in execution path)
{ lib {
, writeShellScriptBin lib,
, extensionsFromVscodeMarketplace writeShellScriptBin,
, vscodeDefault extensionsFromVscodeMarketplace,
vscodeDefault,
}: }:
## User input ## User input
{ vscode ? vscodeDefault {
vscode ? vscodeDefault,
# extensions to be symlinked into the project's extensions folder # extensions to be symlinked into the project's extensions folder
, nixExtensions ? [] nixExtensions ? [ ],
# extensions to be copied into the project's extensions folder # extensions to be copied into the project's extensions folder
, mutableExtensions ? [] mutableExtensions ? [ ],
, vscodeExtsFolderName ? ".vscode-exts" vscodeExtsFolderName ? ".vscode-exts",
, user-data-dir ? ''"''${TMP}vscodeWithConfiguration/vscode-data-dir"'' user-data-dir ? ''"''${TMP}vscodeWithConfiguration/vscode-data-dir"'',
}: }:
let let
nixExtsDrvs = extensionsFromVscodeMarketplace nixExtensions; nixExtsDrvs = extensionsFromVscodeMarketplace nixExtensions;
mutExtsDrvs = extensionsFromVscodeMarketplace mutableExtensions; mutExtsDrvs = extensionsFromVscodeMarketplace mutableExtensions;
mutableExtsPaths = lib.forEach mutExtsDrvs ( e: mutableExtsPaths = lib.forEach mutExtsDrvs (e: {
{
origin = "${e}/share/vscode/extensions/${e.vscodeExtUniqueId}"; origin = "${e}/share/vscode/extensions/${e.vscodeExtUniqueId}";
target = ''${vscodeExtsFolderName}/${e.vscodeExtUniqueId}-${(lib.findSingle (ext: "${ext.publisher}.${ext.name}" == e.vscodeExtUniqueId) "" "m" mutableExtensions ).version}''; target = ''${vscodeExtsFolderName}/${e.vscodeExtUniqueId}-${
} (lib.findSingle (
); ext: "${ext.publisher}.${ext.name}" == e.vscodeExtUniqueId
) "" "m" mutableExtensions).version
}'';
});
#removed not defined extensions #removed not defined extensions
rmExtensions = lib.optionalString (nixExtensions ++ mutableExtensions != [ ]) '' rmExtensions = lib.optionalString (nixExtensions ++ mutableExtensions != [ ]) ''
find ${vscodeExtsFolderName} -mindepth 1 -maxdepth 1 ${ find ${vscodeExtsFolderName} -mindepth 1 -maxdepth 1 ${
lib.concatMapStringsSep " " (e: "! -iname ${e.publisher}.${e.name} ") nixExtensions lib.concatMapStringsSep " " (e: "! -iname ${e.publisher}.${e.name} ") nixExtensions
+ + lib.concatMapStringsSep " " (
lib.concatMapStringsSep " " (e : "! -iname ${e.publisher}.${e.name}-${e.version} ") mutableExtensions e: "! -iname ${e.publisher}.${e.name}-${e.version} "
) mutableExtensions
} -exec rm -rf {} \; } -exec rm -rf {} \;
''; '';
#copy mutable extension out of the nix store #copy mutable extension out of the nix store
cpExtensions = '' cpExtensions = ''
${lib.concatMapStringsSep "\n" (e : "ln -sfn ${e}/share/vscode/extensions/* ${vscodeExtsFolderName}/") nixExtsDrvs} ${lib.concatMapStringsSep "\n" (
e: "ln -sfn ${e}/share/vscode/extensions/* ${vscodeExtsFolderName}/"
) nixExtsDrvs}
${lib.concatMapStringsSep "\n" (ePath: '' ${lib.concatMapStringsSep "\n" (ePath: ''
if [ ! -d ${ePath.target} ]; then if [ ! -d ${ePath.target} ]; then
cp -a ${ePath.origin} ${ePath.target} cp -a ${ePath.origin} ${ePath.target}