nix icon indicating copy to clipboard operation
nix copied to clipboard

Allow store/eval-store to be specified by environment variable

Open kjeremy opened this issue 1 year ago • 1 comments

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.

kjeremy avatar Aug 09 '22 19:08 kjeremy

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).

cole-h avatar Aug 10 '22 14:08 cole-h

This environment variable already exists but its name is inconsistent with the CLI flag: NIX_REMOTE

Atemu avatar Mar 02 '24 13:03 Atemu

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

thufschmitt avatar Mar 04 '24 08:03 thufschmitt