daemon: Define 'NIX_STORE' before invoking 'guix perform-download'.

Reported by rohit yadav <rohityadav@utexas.edu>
at <https://lists.gnu.org/archive/html/guix-devel/2017-02/msg00191.html>.

This fixes a regression whereby 'guix perform-download' would always see
NIX_STORE as unset and thus use "/gnu/store", leading it to miscompute
the hydra.gnu.org content-addressed URLs when the store file name is not
"/gnu/store".

* nix/libstore/builtins.cc (builtinDownload): Add 'setenv' call for
'NIX_STORE'.
This commit is contained in:
Ludovic Courtès 2017-02-07 14:44:55 +01:00
parent ef753a1a8f
commit 328f7cbe43
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 6 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#include <globals.hh> #include <globals.hh>
#include <unistd.h> #include <unistd.h>
#include <cstdlib>
namespace nix { namespace nix {
@ -41,6 +42,11 @@ static void builtinDownload(const Derivation &drv,
"download", drvPath.c_str(), output.c_str(), NULL "download", drvPath.c_str(), output.c_str(), NULL
}; };
/* Tell the script what the store file name is, so that
'strip-store-file-name' (used for instance to determine the URL of
content-addressed mirrors) works correctly. */
setenv("NIX_STORE", settings.nixStore.c_str(), 1);
/* XXX: Hack our way to use the 'download' script from 'LIBEXECDIR/guix' /* XXX: Hack our way to use the 'download' script from 'LIBEXECDIR/guix'
or just 'LIBEXECDIR', depending on whether we're running uninstalled or or just 'LIBEXECDIR', depending on whether we're running uninstalled or
not. */ not. */