2019-12-24 18:15:15 +00:00
#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.
2019-12-28 21:43:41 +00:00
{ lib
, buildEnv
, writeShellScriptBin
, extensionsFromVscodeMarketplace
, vscodeDefault
} :
2019-12-24 18:15:15 +00:00
##User input
2019-12-28 21:43:41 +00:00
{ vscode ? vscodeDefault
, nixExtensions ? [ ]
, vscodeExtsFolderName ? " . v s c o d e - e x t s "
2019-12-24 18:15:15 +00:00
# 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
2019-12-28 21:43:41 +00:00
, mutableExtensionsFile
2019-12-24 18:15:15 +00:00
} :
let
2019-12-28 21:43:41 +00:00
mutableExtensionsFilePath = toString mutableExtensionsFile ;
2019-12-24 18:15:15 +00:00
mutableExtensions = if builtins . pathExists mutableExtensionsFile
then import mutableExtensionsFilePath else [ ] ;
vscodeWithConfiguration = import ./vscodeWithConfiguration.nix {
2019-12-28 21:43:41 +00:00
inherit lib writeShellScriptBin extensionsFromVscodeMarketplace ;
vscodeDefault = vscode ;
}
{
inherit nixExtensions mutableExtensions vscodeExtsFolderName ;
2019-12-24 18:15:15 +00:00
} ;
vscodeExts2nix = import ./vscodeExts2nix.nix {
inherit lib writeShellScriptBin ;
2019-12-28 21:43:41 +00:00
vscodeDefault = vscodeWithConfiguration ;
}
{
2019-12-24 18:15:15 +00:00
extensionsToIgnore = nixExtensions ;
extensions = mutableExtensions ;
} ;
code = writeShellScriptBin " c o d e " ''
$ { vscodeWithConfiguration } /bin/code - - wait " $ @ "
echo ' running vscodeExts2nix to update $ { mutableExtensionsFilePath } . . . '
$ { vscodeExts2nix } /bin/vscodeExts2nix > $ { mutableExtensionsFilePath }
'' ;
in
2019-12-28 21:43:41 +00:00
buildEnv {
2019-12-24 18:15:15 +00:00
name = " v s c o d e E n v " ;
paths = [ code vscodeExts2nix ] ;
}