nixpkgs/pkgs/misc/vscode-extensions/vscodeEnv.nix
Oren Rozen 4b25c6ac51 vscode-utils/vscodeEnv: add vscodeWithConfiguration, vscodeExts2nix and vscodeEnv
move mktplcExtRefToFetchArgs to file in order to be shared with the new derivations(privately)
2019-12-24 13:15:15 -05:00

40 lines
1.7 KiB
Nix

#use vscodeWithConfiguration and vscodeExts2nix to create vscode exetuable that when exits(vscode) will update the mutable extension file, which is imported when getting evaluated by nix.
{ pkgs ? import <nixpkgs> {}
, lib ? pkgs.lib
, writeShellScriptBin ? pkgs.writeShellScriptBin
, extensionsFromVscodeMarketplace ? pkgs.vscode-utils.extensionsFromVscodeMarketplace
##User input
, nixExtensions ? []
# 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 ? ./extensions.nix
, vscodeExtsFolderName ? ".vscode-exts"
, vscode ? pkgs.vscode
}:
let
mutableExtensionsFilePath = builtins.toPath mutableExtensionsFile;
mutableExtensions = if builtins.pathExists mutableExtensionsFile
then import mutableExtensionsFilePath else [];
vscodeWithConfiguration = import ./vscodeWithConfiguration.nix {
inherit lib writeShellScriptBin vscode extensionsFromVscodeMarketplace
nixExtensions mutableExtensions vscodeExtsFolderName;
};
vscodeExts2nix = import ./vscodeExts2nix.nix {
inherit lib writeShellScriptBin;
extensionsToIgnore = nixExtensions;
extensions = mutableExtensions;
vscode = vscodeWithConfiguration;
};
code = writeShellScriptBin "code" ''
${vscodeWithConfiguration}/bin/code --wait "$@"
echo 'running vscodeExts2nix to update ${mutableExtensionsFilePath}...'
${vscodeExts2nix}/bin/vscodeExts2nix > ${mutableExtensionsFilePath}
'';
in
pkgs.buildEnv {
name = "vscodeEnv";
paths = [ code vscodeExts2nix ];
}