devshell
devshell copied to clipboard
`env`: Consider adding `separator` option for `prefix` env vars
Is your feature request related to a problem? Please describe.
I can define an env var with prefix
to prefix a path onto a :-separated PATH-like variable. However there's no convenience for prefixing onto other types of variables. In my case I want to add something to NIX_CONFIG
, which is a newline-separated variable. And today I have to write this like
{
env = [{
name = "NIX_CONFIG";
eval = ''"builders = "${lib.escapeShellArg builderConfig}''${NIX_CONFIG:+$'\n'"$NIX_CONFIG"}'';
}];
}
Describe the solution you'd like
I'd like to have a separator
option which I can set to something other than ":"
.
This also requires some way to disable the realpath
invocation. That makes sense for PATH-like prefixing but not for other variables. One possibility here is to say "if you define the separator
option it disables path expansion, even if you set it to ":"
". This would allow my definition above to look like
{
env = [{
name = "NIX_CONFIG";
prefix = builderConfig;
separator = "\n";
}];
}
Describe alternatives you've considered
With this I'd also like to be able to suffix the variable too, not just prefix. That is possibly useful for PATH-like variables too, although much less common, but e.g. in my case I'd prefer to suffix instead of prefix to ensure my definition actually works even if the inherited $NIX_CONFIG
already tries to define the key.
Why not? It makes me think of wrapProgram, maybe the env option should be modeled after its options, so there is some transferable knowledge there.