From f32cdc4fab1bff919c3d074a95e32a9934eb7386 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 23 Oct 2017 19:34:49 +0200 Subject: [PATCH] Turn $NIX_REMOTE into a configuration option --- src/libstore/globals.hh | 4 ++++ src/libstore/store-api.hh | 5 +++-- src/nix/command.cc | 5 +---- src/nix/command.hh | 1 - 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index 264e82a16..12d57b3e7 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -2,6 +2,7 @@ #include "types.hh" #include "config.hh" +#include "util.hh" #include #include @@ -84,6 +85,9 @@ public: /* File name of the socket the daemon listens to. */ Path nixDaemonSocketFile; + Setting storeUri{this, getEnv("NIX_REMOTE", "auto"), "store", + "The default Nix store to use."}; + Setting keepFailed{this, false, "keep-failed", "Whether to keep temporary directories of failed builds."}; diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 5f3d8c7b9..d1e1b5d6f 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -716,7 +716,7 @@ void removeTempRoots(); You can pass parameters to the store implementation by appending ‘?key=value&key=value&...’ to the URI. */ -ref openStore(const std::string & uri = getEnv("NIX_REMOTE"), +ref openStore(const std::string & uri = settings.storeUri.get(), const Store::Params & extraParams = Store::Params()); @@ -727,7 +727,8 @@ enum StoreType { }; -StoreType getStoreType(const std::string & uri = getEnv("NIX_REMOTE"), const std::string & stateDir = settings.nixStateDir); +StoreType getStoreType(const std::string & uri = settings.storeUri.get(), + const std::string & stateDir = settings.nixStateDir); /* Return the default substituter stores, defined by the ‘substituters’ option and various legacy options like diff --git a/src/nix/command.cc b/src/nix/command.cc index 0f6bb294b..70d642605 100644 --- a/src/nix/command.cc +++ b/src/nix/command.cc @@ -78,9 +78,6 @@ bool MultiCommand::processArgs(const Strings & args, bool finish) StoreCommand::StoreCommand() { - storeUri = getEnv("NIX_REMOTE"); - - mkFlag(0, "store", "store-uri", "URI of the Nix store to use", &storeUri); } ref StoreCommand::getStore() @@ -92,7 +89,7 @@ ref StoreCommand::getStore() ref StoreCommand::createStore() { - return openStore(storeUri); + return openStore(); } void StoreCommand::run() diff --git a/src/nix/command.hh b/src/nix/command.hh index bf897f620..77ca8cfb6 100644 --- a/src/nix/command.hh +++ b/src/nix/command.hh @@ -33,7 +33,6 @@ class Store; /* A command that require a Nix store. */ struct StoreCommand : virtual Command { - std::string storeUri; StoreCommand(); void run() override; ref getStore();