utils: Add NIX_STORE_DIR as a candidate for the value of the store directory.

On the daemon side, nixStore gets set to the environment variable
NIX_STORE_DIR, else the environment variable NIX_STORE else the compile time
macro NIX_STORE_DIR (see the Settings::processEnvironment method in
nix/libstore/globals.cc).  When creating a build environment, it sets
NIX_STORE with the value computed as described above.  Hence, it's safer to
look for both NIX_STORE_DIR and NIX_STORE in (guix build utils), so that it
works in any context (build context or external context).

* guix/build/utils.scm (%store-directory): Consider both NIX_STORE_DIR and
NIX_STORE as environment variables.
This commit is contained in:
Maxim Cournoyer 2021-01-18 11:51:20 -05:00
parent 94cf367634
commit 47a6a938c3
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -144,7 +144,8 @@ (define (setvbuf port mode . rest)
(define (%store-directory)
"Return the directory name of the store."
(or (getenv "NIX_STORE")
(or (getenv "NIX_STORE_DIR") ;outside of builder
(getenv "NIX_STORE") ;inside builder, set by the daemon
"/gnu/store"))
(define (store-file-name? file)