Working on custom vscode module but environment variable flag isn't properly expanding due to single quotes. #509
-
|
I was hoping to create a quick and dirty wrapper for vscode for personal use but I ran into an issue. Here's what I have
{
wlib,
config,
pkgs,
lib,
...
}:
let
cfg = config;
in
{
imports = [ wlib.modules.default ];
options = {
extensions = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
};
userSettings = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
default = { };
};
};
config = {
package = lib.mkDefault pkgs.vscode;
runShell = let
settingsFile = pkgs.writeText "settings.json" (builtins.toJSON cfg.userSettings);
in [''
tmp_user_data_dir=$(mktemp -d)
echo "Created session directory: $tmp_user_data_dir"
cp ${settingsFile} "$tmp_user_data_dir/settings.json"
''];
flags = lib.mkMerge [
(lib.mkIf (cfg.extensions != [ ]) {
"--extensions-dir" = "${pkgs.buildEnv {
name = "vscode-extensions";
paths = cfg.extensions;
}}/share/vscode/extensions";
})
{
"--user-data-dir" = wlib.escapeShellArgWithEnv "\$tmp_user_data_dir";
}
];
};
}now I'm having an issue where the parameter |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
per-item https://birdeehub.github.io/nix-wrapper-modules/modules/makeWrapper.html#flagsnameesc-fn default https://birdeehub.github.io/nix-wrapper-modules/modules/makeWrapper.html#escapingfunction example nix-wrapper-modules/wrapperModules/n/nh/module.nix Lines 19 to 24 in dc51840 ^ this one is for the env set, but flags can do this too |
Beta Was this translation helpful? Give feedback.
per-item
https://birdeehub.github.io/nix-wrapper-modules/modules/makeWrapper.html#flagsnameesc-fn
default
https://birdeehub.github.io/nix-wrapper-modules/modules/makeWrapper.html#escapingfunction
example
nix-wrapper-modules/wrapperModules/n/nh/module.nix
Lines 19 to 24 in dc51840
^ this one is for the env set, but flags can do this too