forked from mirrors/nixpkgs
use updateSettings in vscodeEnv in order to create and/or update settings.json, keybindings.json
This commit is contained in:
parent
a535e7a04f
commit
0e4ac8bf83
|
@ -4,11 +4,18 @@
|
|||
, writeShellScriptBin
|
||||
, extensionsFromVscodeMarketplace
|
||||
, vscodeDefault
|
||||
, jq
|
||||
}:
|
||||
##User input
|
||||
{ vscode ? vscodeDefault
|
||||
, nixExtensions ? []
|
||||
, vscodeExtsFolderName ? ".vscode-exts"
|
||||
{ vscode ? vscodeDefault
|
||||
, nixExtensions ? []
|
||||
, vscodeExtsFolderName ? ".vscode-exts"
|
||||
# will add to the command updateSettings (which will run on executing vscode) settings to override in settings.json file
|
||||
, settings ? {}
|
||||
, createSettingsIfDoesNotExists ? true
|
||||
# will add to the command updateKeybindings(which will run on executing vscode) keybindings to override in keybinding.json file
|
||||
, keybindings ? {}
|
||||
, createKeybindingsIfDoesNotExists ? true
|
||||
# if file exists will use it and import the extensions in it into this dervation else will use empty extensions list
|
||||
# this file will be created/updated by vscodeExts2nix when vscode exists
|
||||
, mutableExtensionsFile
|
||||
|
@ -25,6 +32,19 @@ let
|
|||
inherit nixExtensions mutableExtensions vscodeExtsFolderName;
|
||||
};
|
||||
|
||||
updateSettings = import ./updateSettings.nix { inherit lib writeShellScriptBin jq; };
|
||||
|
||||
updateSettingsCmd = updateSettings {
|
||||
inherit settings;
|
||||
createIfDoesNotExists = createSettingsIfDoesNotExists;
|
||||
};
|
||||
|
||||
updateKeybindingsCmd = updateSettings {
|
||||
settings = keybindings;
|
||||
createIfDoesNotExists = createKeybindingsIfDoesNotExists;
|
||||
vscodeSettingsFile = .vscode/keybindings.json;
|
||||
};
|
||||
|
||||
vscodeExts2nix = import ./vscodeExts2nix.nix {
|
||||
inherit lib writeShellScriptBin;
|
||||
vscodeDefault = vscodeWithConfiguration;
|
||||
|
@ -34,6 +54,8 @@ let
|
|||
extensions = mutableExtensions;
|
||||
};
|
||||
code = writeShellScriptBin "code" ''
|
||||
${updateSettingsCmd}/bin/vscodeNixUpdate-settings
|
||||
${updateKeybindingsCmd}/bin/vscodeNixUpdate-keybindings
|
||||
${vscodeWithConfiguration}/bin/code --wait "$@"
|
||||
echo 'running vscodeExts2nix to update ${mutableExtensionsFilePath}...'
|
||||
${vscodeExts2nix}/bin/vscodeExts2nix > ${mutableExtensionsFilePath}
|
||||
|
@ -41,5 +63,5 @@ let
|
|||
in
|
||||
buildEnv {
|
||||
name = "vscodeEnv";
|
||||
paths = [ code vscodeExts2nix ];
|
||||
paths = [ code vscodeExts2nix updateSettingsCmd updateKeybindingsCmd ];
|
||||
}
|
||||
|
|
12
pkgs/misc/vscode-extensions/vscodeEnvTest.nix
Normal file
12
pkgs/misc/vscode-extensions/vscodeEnvTest.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
with import <nixpkgs>{};
|
||||
callPackage (import ./vscodeEnv.nix) {
|
||||
extensionsFromVscodeMarketplace = vscode-utils.extensionsFromVscodeMarketplace;
|
||||
vscodeDefault = vscode;
|
||||
} {
|
||||
mutableExtensionsFile = ./extensions.nix;
|
||||
settings = {
|
||||
a = "fdsdf";
|
||||
t = "test";
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in a new issue