From a87d66f371da2a84d7bba1cae58b71c9c9af73aa Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 3 Feb 2019 22:10:06 +0100 Subject: daemon: Rename 'NIX_STATE_DIR' and 'NIX_DB_DIR' environment variables. Fixes . Reported by Jeff Mickey . * guix/config.scm.in (%state-directory): Change NIX_STATE_DIR to GUIX_STATE_DIRECTORY. (%store-database-directory): Change NIX_DB_DIR to GUIX_DATABASE_DIRECTORY. * nix/libstore/globals.cc (Settings::processEnvironment): Likewise. * guix/self.scm (make-config.scm): Likewise. * build-aux/build-self.scm (make-config.scm): Likewise. * build-aux/test-env.in: Likewise. * tests/derivations.scm ("derivation #:leaked-env-vars"): Likewise. * tests/guix-build.sh (GUIX_DAEMON_SOCKET): Likewise. * tests/guix-daemon.sh (socket): Likewise. --- nix/libstore/globals.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'nix') diff --git a/nix/libstore/globals.cc b/nix/libstore/globals.cc index 25f80da2dd..ac92971887 100644 --- a/nix/libstore/globals.cc +++ b/nix/libstore/globals.cc @@ -67,9 +67,9 @@ void Settings::processEnvironment() { nixStore = canonPath(getEnv("NIX_STORE_DIR", getEnv("NIX_STORE", NIX_STORE_DIR))); nixDataDir = canonPath(getEnv("NIX_DATA_DIR", NIX_DATA_DIR)); - nixLogDir = canonPath(getEnv("NIX_LOG_DIR", NIX_LOG_DIR)); - nixStateDir = canonPath(getEnv("NIX_STATE_DIR", NIX_STATE_DIR)); - nixDBPath = getEnv("NIX_DB_DIR", nixStateDir + "/db"); + nixLogDir = canonPath(getEnv("GUIX_LOG_DIRECTORY", NIX_LOG_DIR)); + nixStateDir = canonPath(getEnv("GUIX_STATE_DIRECTORY", NIX_STATE_DIR)); + nixDBPath = getEnv("GUIX_DATABASE_DIRECTORY", nixStateDir + "/db"); nixConfDir = canonPath(getEnv("GUIX_CONFIGURATION_DIRECTORY", GUIX_CONFIGURATION_DIRECTORY)); nixLibexecDir = canonPath(getEnv("NIX_LIBEXEC_DIR", NIX_LIBEXEC_DIR)); nixBinDir = canonPath(getEnv("NIX_BIN_DIR", NIX_BIN_DIR)); -- cgit v1.2.3 From 65d13e3043d90382f79b1780e06dc671ae451edf Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 3 Feb 2019 22:30:18 +0100 Subject: daemon: Remove unused 'NIX_DATA_DIR' environment variable. * nix/libstore/globals.hh (Settings)[nixDataDir]: Remove. * nix/libstore/globals.cc (Settings:processEnvironment): Remove setting of 'nixDataDir'. * nix/local.mk (libstore_a_CPPFLAGS): Remove '-DNIX_DATA_DIR'. --- nix/libstore/globals.cc | 1 - nix/libstore/globals.hh | 2 -- nix/local.mk | 3 +-- 3 files changed, 1 insertion(+), 5 deletions(-) (limited to 'nix') diff --git a/nix/libstore/globals.cc b/nix/libstore/globals.cc index ac92971887..130b0937fd 100644 --- a/nix/libstore/globals.cc +++ b/nix/libstore/globals.cc @@ -66,7 +66,6 @@ Settings::Settings() void Settings::processEnvironment() { nixStore = canonPath(getEnv("NIX_STORE_DIR", getEnv("NIX_STORE", NIX_STORE_DIR))); - nixDataDir = canonPath(getEnv("NIX_DATA_DIR", NIX_DATA_DIR)); nixLogDir = canonPath(getEnv("GUIX_LOG_DIRECTORY", NIX_LOG_DIR)); nixStateDir = canonPath(getEnv("GUIX_STATE_DIRECTORY", NIX_STATE_DIR)); nixDBPath = getEnv("GUIX_DATABASE_DIRECTORY", nixStateDir + "/db"); diff --git a/nix/libstore/globals.hh b/nix/libstore/globals.hh index a6935c3337..b073f724b6 100644 --- a/nix/libstore/globals.hh +++ b/nix/libstore/globals.hh @@ -45,8 +45,6 @@ struct Settings { /* The directory where we store sources and derived files. */ Path nixStore; - Path nixDataDir; /* !!! fix */ - /* The directory where we log various operations. */ Path nixLogDir; diff --git a/nix/local.mk b/nix/local.mk index fe45c344f0..ca958ff500 100644 --- a/nix/local.mk +++ b/nix/local.mk @@ -1,5 +1,5 @@ # GNU Guix --- Functional package management for GNU -# Copyright © 2012, 2013, 2014, 2015, 2016, 2018 Ludovic Courtès +# Copyright © 2012, 2013, 2014, 2015, 2016, 2018, 2019 Ludovic Courtès # Copyright © 2016 Mathieu Lirzin # # This file is part of GNU Guix. @@ -107,7 +107,6 @@ libstore_a_CPPFLAGS = \ -I$(top_srcdir)/%D%/libstore \ -I$(top_builddir)/%D%/libstore \ -DNIX_STORE_DIR=\"$(storedir)\" \ - -DNIX_DATA_DIR=\"$(datadir)\" \ -DNIX_STATE_DIR=\"$(localstatedir)/guix\" \ -DNIX_LOG_DIR=\"$(localstatedir)/log/guix\" \ -DGUIX_CONFIGURATION_DIRECTORY=\"$(sysconfdir)/guix\" \ -- cgit v1.2.3 From 4d4a38f620520acc787ff5db2be3736923e14235 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 4 Feb 2019 14:17:46 +0100 Subject: daemon: Remove the 'NIX_SUBSTITUTERS' environment variable. * nix/libstore/globals.cc (Settings:update): Remove changes to 'substituters'. * nix/nix-daemon/guix-daemon.cc (main): Set 'settings.substituters' directly instead of changing the 'NIX_SUBSTITUTERS' environment variable. * build-aux/pre-inst-env.in: Remove reference to 'NIX_SUBSTITUTERS'. --- build-aux/pre-inst-env.in | 5 ++--- nix/libstore/globals.cc | 12 ------------ nix/nix-daemon/guix-daemon.cc | 23 ++++++++++------------- 3 files changed, 12 insertions(+), 28 deletions(-) (limited to 'nix') diff --git a/build-aux/pre-inst-env.in b/build-aux/pre-inst-env.in index 286a81591c..050b1b8007 100644 --- a/build-aux/pre-inst-env.in +++ b/build-aux/pre-inst-env.in @@ -1,7 +1,7 @@ #!/bin/sh # GNU Guix --- Functional package management for GNU -# Copyright © 2012, 2013, 2014, 2015, 2017, 2018 Ludovic Courtès +# Copyright © 2012, 2013, 2014, 2015, 2017, 2018, 2019 Ludovic Courtès # Copyright © 2017 Eric Bavier # # This file is part of GNU Guix. @@ -45,10 +45,9 @@ export PATH # Daemon helpers. NIX_ROOT_FINDER="$abs_top_builddir/nix/scripts/list-runtime-roots" -NIX_SUBSTITUTERS="$abs_top_builddir/nix/scripts/substitute" NIX_LIBEXEC_DIR="@abs_top_builddir@/nix/scripts" # for 'guix-authenticate' -export NIX_ROOT_FINDER NIX_SUBSTITUTERS NIX_LIBEXEC_DIR +export NIX_ROOT_FINDER NIX_LIBEXEC_DIR NIX_BUILD_HOOK="$abs_top_builddir/nix/scripts/offload" @BUILD_DAEMON_OFFLOAD_TRUE@export NIX_BUILD_HOOK diff --git a/nix/libstore/globals.cc b/nix/libstore/globals.cc index 130b0937fd..69f6d06563 100644 --- a/nix/libstore/globals.cc +++ b/nix/libstore/globals.cc @@ -141,18 +141,6 @@ void Settings::update() _get(gcKeepDerivations, "gc-keep-derivations"); _get(autoOptimiseStore, "auto-optimise-store"); _get(envKeepDerivations, "env-keep-derivations"); - - string subs = getEnv("NIX_SUBSTITUTERS", "default"); - if (subs == "default") { - substituters.clear(); -#if 0 - if (getEnv("NIX_OTHER_STORES") != "") - substituters.push_back(nixLibexecDir + "/nix/substituters/copy-from-other-stores.pl"); -#endif - substituters.push_back(nixLibexecDir + "/nix/substituters/download-using-manifests.pl"); - substituters.push_back(nixLibexecDir + "/nix/substituters/download-from-binary-cache.pl"); - } else - substituters = tokenizeString(subs, ":"); } diff --git a/nix/nix-daemon/guix-daemon.cc b/nix/nix-daemon/guix-daemon.cc index 8fdab2d116..23ef46ef8c 100644 --- a/nix/nix-daemon/guix-daemon.cc +++ b/nix/nix-daemon/guix-daemon.cc @@ -1,5 +1,5 @@ /* GNU Guix --- Functional package management for GNU - Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès + Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès Copyright (C) 2006, 2010, 2012, 2014 Eelco Dolstra This file is part of GNU Guix. @@ -499,22 +499,19 @@ main (int argc, char *argv[]) if (settings.useSubstitutes) { - string subs = getEnv ("NIX_SUBSTITUTERS", "default"); - - if (subs == "default") - { - string subst = - settings.nixLibexecDir + "/guix/substitute"; - setenv ("NIX_SUBSTITUTERS", subst.c_str (), 1); - } + /* XXX: Hack our way to use the 'substitute' script from + 'LIBEXECDIR/guix' or just 'LIBEXECDIR', depending on whether + we're running uninstalled or not. */ + const string subdir = getenv("GUIX_UNINSTALLED") != NULL + ? "" : "/guix"; + + settings.substituters.push_back (settings.nixLibexecDir + + subdir + "/substitute"); } else /* Clear the substituter list to make sure nothing ever gets substituted, regardless of the client's settings. */ - setenv ("NIX_SUBSTITUTERS", "", 1); - - /* Effect the $NIX_SUBSTITUTERS change. */ - settings.update (); + settings.substituters.clear (); if (geteuid () == 0 && settings.buildUsersGroup.empty ()) fprintf (stderr, _("warning: daemon is running as root, so \ -- cgit v1.2.3 From 959eaa1eb834fd47ceab3c5bbbe4967e808d530b Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 4 Feb 2019 16:14:09 +0100 Subject: daemon: Add "/guix" to default 'nixLibexecDir'. This makes it easier to run the uninstalled daemon. * nix/local.mk (libstore_a_CPPFLAGS): Append "/guix" to NIX_LIBEXEC_DIR. * build-aux/pre-inst-env.in (NIX_LIBEXEC_DIR): Adjust comment. * nix/libstore/builtins.cc (builtinDownload): Remove SUBDIR and its use. * nix/libstore/local-store.cc (runAuthenticationProgram): Ditto. * nix/libstore/gc.cc (addAdditionalRoots): Remove "/guix" prefix. * nix/nix-daemon/guix-daemon.cc (main): Ditto. --- build-aux/pre-inst-env.in | 2 +- nix/libstore/builtins.cc | 10 ++-------- nix/libstore/gc.cc | 2 +- nix/libstore/local-store.cc | 10 ++-------- nix/local.mk | 2 +- nix/nix-daemon/guix-daemon.cc | 14 +++----------- 6 files changed, 10 insertions(+), 30 deletions(-) (limited to 'nix') diff --git a/build-aux/pre-inst-env.in b/build-aux/pre-inst-env.in index 050b1b8007..3efab69e7d 100644 --- a/build-aux/pre-inst-env.in +++ b/build-aux/pre-inst-env.in @@ -45,7 +45,7 @@ export PATH # Daemon helpers. NIX_ROOT_FINDER="$abs_top_builddir/nix/scripts/list-runtime-roots" -NIX_LIBEXEC_DIR="@abs_top_builddir@/nix/scripts" # for 'guix-authenticate' +NIX_LIBEXEC_DIR="@abs_top_builddir@/nix/scripts" # for 'authenticate', etc. export NIX_ROOT_FINDER NIX_LIBEXEC_DIR diff --git a/nix/libstore/builtins.cc b/nix/libstore/builtins.cc index 1f52511c80..f7c7d42484 100644 --- a/nix/libstore/builtins.cc +++ b/nix/libstore/builtins.cc @@ -1,5 +1,5 @@ /* GNU Guix --- Functional package management for GNU - Copyright (C) 2016, 2017, 2018 Ludovic Courtès + Copyright (C) 2016, 2017, 2018, 2019 Ludovic Courtès This file is part of GNU Guix. @@ -50,13 +50,7 @@ static void builtinDownload(const Derivation &drv, /* Tell it about options such as "print-extended-build-trace". */ setenv("_NIX_OPTIONS", settings.pack().c_str(), 1); - /* XXX: Hack our way to use the 'download' script from 'LIBEXECDIR/guix' - or just 'LIBEXECDIR', depending on whether we're running uninstalled or - not. */ - const string subdir = getenv("GUIX_UNINSTALLED") != NULL - ? "" : "/guix"; - - const string program = settings.nixLibexecDir + subdir + "/download"; + const string program = settings.nixLibexecDir + "/download"; execv(program.c_str(), (char *const *) argv); throw SysError(format("failed to run download program '%1%'") % program); diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc index 125f242814..310b8792fe 100644 --- a/nix/libstore/gc.cc +++ b/nix/libstore/gc.cc @@ -340,7 +340,7 @@ Roots LocalStore::findRoots() static void addAdditionalRoots(StoreAPI & store, PathSet & roots) { Path rootFinder = getEnv("NIX_ROOT_FINDER", - settings.nixLibexecDir + "/guix/list-runtime-roots"); + settings.nixLibexecDir + "/list-runtime-roots"); if (rootFinder.empty()) return; diff --git a/nix/libstore/local-store.cc b/nix/libstore/local-store.cc index eb8a51cc23..892d9300b1 100644 --- a/nix/libstore/local-store.cc +++ b/nix/libstore/local-store.cc @@ -1224,14 +1224,8 @@ static void checkSecrecy(const Path & path) static std::string runAuthenticationProgram(const Strings & args) { - /* Use the 'authenticate' script from 'LIBEXECDIR/guix' or just - 'LIBEXECDIR', depending on whether we're uninstalled or not. */ - const bool installed = getenv("GUIX_UNINSTALLED") == NULL; - const string program = settings.nixLibexecDir - + (installed ? "/guix" : "") - + "/authenticate"; - - return runProgram(program, false, args); + return runProgram(settings.nixLibexecDir + "/authenticate", + false, args); } void LocalStore::exportPath(const Path & path, bool sign, diff --git a/nix/local.mk b/nix/local.mk index ca958ff500..6d7e60e9fb 100644 --- a/nix/local.mk +++ b/nix/local.mk @@ -110,7 +110,7 @@ libstore_a_CPPFLAGS = \ -DNIX_STATE_DIR=\"$(localstatedir)/guix\" \ -DNIX_LOG_DIR=\"$(localstatedir)/log/guix\" \ -DGUIX_CONFIGURATION_DIRECTORY=\"$(sysconfdir)/guix\" \ - -DNIX_LIBEXEC_DIR=\"$(libexecdir)\" \ + -DNIX_LIBEXEC_DIR=\"$(libexecdir)/guix\" \ -DNIX_BIN_DIR=\"$(bindir)\" \ -DDEFAULT_CHROOT_DIRS="\"\"" diff --git a/nix/nix-daemon/guix-daemon.cc b/nix/nix-daemon/guix-daemon.cc index 23ef46ef8c..f47d142612 100644 --- a/nix/nix-daemon/guix-daemon.cc +++ b/nix/nix-daemon/guix-daemon.cc @@ -480,7 +480,7 @@ main (int argc, char *argv[]) { std::string build_hook; - build_hook = settings.nixLibexecDir + "/guix/offload"; + build_hook = settings.nixLibexecDir + "/offload"; setenv ("NIX_BUILD_HOOK", build_hook.c_str (), 1); } #else @@ -498,16 +498,8 @@ main (int argc, char *argv[]) format ("build log compression: %1%") % settings.logCompression); if (settings.useSubstitutes) - { - /* XXX: Hack our way to use the 'substitute' script from - 'LIBEXECDIR/guix' or just 'LIBEXECDIR', depending on whether - we're running uninstalled or not. */ - const string subdir = getenv("GUIX_UNINSTALLED") != NULL - ? "" : "/guix"; - - settings.substituters.push_back (settings.nixLibexecDir - + subdir + "/substitute"); - } + settings.substituters.push_back (settings.nixLibexecDir + + "/substitute"); else /* Clear the substituter list to make sure nothing ever gets substituted, regardless of the client's settings. */ -- cgit v1.2.3