nix
nix copied to clipboard
Allow store/eval-store to be specified by environment variable
Is your feature request related to a problem? Please describe.
We are attempting to build in a docker container with nix installed using a bind mounted directory (/srv/nix
) shared between a few containers: one does the actual building, a container running the daemon and another container running nix-serve
. Each operation requires specifying the store ex. nix build --store /srv/nix --eval-store local nixpkgs#hello
. It would be nice if we could set up an environment variable before these operations. Something like NIX_STORE_PATH=/srv/nix
and then run our operations.
Describe the solution you'd like
Specifying NIX_STORE_PATH=/srv/nix
in the environment should make nix build nixpkgs#hello
behave as if nix build --store /srv/nix --eval-store local nixpkgs#hello
was run.
Describe alternatives you've considered Specifying everything on the command line.
Additional context
Multiple docker containers sharing the /nix/store in a docker volume mounted in each containers as /srv/nix
.
I tested this just now, and it seems like you can specify the store
in the nix.conf
file (e.g. in /etc/nix/nix.conf
or ~/.config/nix/nix.conf
).
This environment variable already exists but its name is inconsistent with the CLI flag: NIX_REMOTE
For a consistent way of defining that, you can also set NIX_CONFIG="store = /srv/nix"
. That doesn't work for the eval-store
though because it's not a config option but just a cli flag