#540

multiple `env-file` settings

OpenMagicRBopened 7mo ago

Your background

Maintainer of NixNG

The problem

In NixNG we allow the user to specify both environment variables statically as part of Nix evaluation and also a environment file which should be loaded at runtime, the idea is to be able to set PATH to something as well as pass secrets/configs to services which accept secrets/config via environment variables. Without plural env-file we'd have no way to combine the two env files and we'd have to resort to running every service in a script or another compiled binary. Currently this is blocking a dinit upgrade...

The solution Make env-file and a list settings, I already had a patch for that but it doesn't apply anymore and with the recent "make env-file handle relative paths based on the service directory" changes, I'm not confident in up-porting the patch. Not sure how to handle the dirfd's correctly.

Activity

4
MagicRB7mo ago

as a side-note, i would have sworn on my life i contributed that patch upstream, i guess i did not.

MagicRB7mo ago

I managed to revert the "use openat for env-file" commit (sorry i dont have the hash on hand) and dinit compiles and works afaict. So good enough as a stop gap, but i'd prefer if we didnt carry OOT patches

davmac3147mo ago

I have some thoughts about revamping the processing of service descriptions at some point, that would make this easy; right now I want to focus on a 1.0 release, so it might have to wait until after that.

Until then, your patch looks mostly ok, but I think that it prevents "pre-load" variable expansion for happening for any of the specified env files (eg you won't be able to use "$HOME" in the setting). Also it resolves all environment file paths against the main service directory, not the fragment that specified the setting (this was one of the things that the "use openat for env-file" patch likely did). And of course it doesn't update the documentation with the changes :)

MagicRB7mo ago

Okay, ill leave you to focus on 1.0, we'll roll with the patch for now. I don't want to step on your toes with this.

P.S. docs? Never heard of then, just read the code I say! ;)