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
|
, writeShellScriptBin
|
||||||
, extensionsFromVscodeMarketplace
|
, extensionsFromVscodeMarketplace
|
||||||
, vscodeDefault
|
, vscodeDefault
|
||||||
|
, jq
|
||||||
}:
|
}:
|
||||||
##User input
|
##User input
|
||||||
{ vscode ? vscodeDefault
|
{ vscode ? vscodeDefault
|
||||||
, nixExtensions ? []
|
, nixExtensions ? []
|
||||||
, vscodeExtsFolderName ? ".vscode-exts"
|
, 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
|
# 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
|
# this file will be created/updated by vscodeExts2nix when vscode exists
|
||||||
, mutableExtensionsFile
|
, mutableExtensionsFile
|
||||||
@ -25,6 +32,19 @@ let
|
|||||||
inherit nixExtensions mutableExtensions vscodeExtsFolderName;
|
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 {
|
vscodeExts2nix = import ./vscodeExts2nix.nix {
|
||||||
inherit lib writeShellScriptBin;
|
inherit lib writeShellScriptBin;
|
||||||
vscodeDefault = vscodeWithConfiguration;
|
vscodeDefault = vscodeWithConfiguration;
|
||||||
@ -34,6 +54,8 @@ let
|
|||||||
extensions = mutableExtensions;
|
extensions = mutableExtensions;
|
||||||
};
|
};
|
||||||
code = writeShellScriptBin "code" ''
|
code = writeShellScriptBin "code" ''
|
||||||
|
${updateSettingsCmd}/bin/vscodeNixUpdate-settings
|
||||||
|
${updateKeybindingsCmd}/bin/vscodeNixUpdate-keybindings
|
||||||
${vscodeWithConfiguration}/bin/code --wait "$@"
|
${vscodeWithConfiguration}/bin/code --wait "$@"
|
||||||
echo 'running vscodeExts2nix to update ${mutableExtensionsFilePath}...'
|
echo 'running vscodeExts2nix to update ${mutableExtensionsFilePath}...'
|
||||||
${vscodeExts2nix}/bin/vscodeExts2nix > ${mutableExtensionsFilePath}
|
${vscodeExts2nix}/bin/vscodeExts2nix > ${mutableExtensionsFilePath}
|
||||||
@ -41,5 +63,5 @@ let
|
|||||||
in
|
in
|
||||||
buildEnv {
|
buildEnv {
|
||||||
name = "vscodeEnv";
|
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…
x
Reference in New Issue
Block a user