From a91954f0c658e90b08f7f6e371305281e4d7d329 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Fri, 2 Sep 2016 06:35:48 -0400 Subject: [PATCH] Merge openStore and openStoreAt with default arguments --- src/libstore/store-api.cc | 10 ++-------- src/libstore/store-api.hh | 6 +----- src/nix/command.cc | 2 +- src/nix/copy.cc | 4 ++-- src/nix/sigs.cc | 2 +- src/nix/verify.cc | 2 +- 6 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 5dd56f905..75456ab8c 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -506,7 +506,7 @@ namespace nix { RegisterStoreImplementation::Implementations * RegisterStoreImplementation::implementations = 0; -ref openStoreAt(const std::string & uri_) +ref openStore(const std::string & uri_) { auto uri(uri_); Store::Params params; @@ -529,12 +529,6 @@ ref openStoreAt(const std::string & uri_) } -ref openStore() -{ - return openStoreAt(getEnv("NIX_REMOTE")); -} - - static RegisterStoreImplementation regStore([]( const std::string & uri, const Store::Params & params) -> std::shared_ptr @@ -579,7 +573,7 @@ std::list> getDefaultSubstituters() auto addStore = [&](const std::string & uri) { if (done.count(uri)) return; done.insert(uri); - state->stores.push_back(openStoreAt(uri)); + state->stores.push_back(openStore(uri)); }; for (auto uri : settings.get("substituters", Strings())) diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 41fc58fc4..76a2f5e9c 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -587,11 +587,7 @@ void removeTempRoots(); If ‘uri’ is empty, it defaults to ‘direct’ or ‘daemon’ depending on whether the user has write access to the local Nix store/database. set to true *unless* you're going to collect garbage. */ -ref openStoreAt(const std::string & uri); - - -/* Open the store indicated by the ‘NIX_REMOTE’ environment variable. */ -ref openStore(); +ref openStore(const std::string & uri = getEnv("NIX_REMOTE")); /* Return the default substituter stores, defined by the diff --git a/src/nix/command.cc b/src/nix/command.cc index 37534015b..fdf6ae6af 100644 --- a/src/nix/command.cc +++ b/src/nix/command.cc @@ -81,7 +81,7 @@ StoreCommand::StoreCommand() void StoreCommand::run() { - run(openStoreAt(storeUri)); + run(openStore(storeUri)); } StorePathsCommand::StorePathsCommand() diff --git a/src/nix/copy.cc b/src/nix/copy.cc index de306cbf9..e8317dc39 100644 --- a/src/nix/copy.cc +++ b/src/nix/copy.cc @@ -43,8 +43,8 @@ struct CmdCopy : StorePathsCommand if (srcUri.empty() && dstUri.empty()) throw UsageError("you must pass ‘--from’ and/or ‘--to’"); - ref srcStore = srcUri.empty() ? store : openStoreAt(srcUri); - ref dstStore = dstUri.empty() ? store : openStoreAt(dstUri); + ref srcStore = srcUri.empty() ? store : openStore(srcUri); + ref dstStore = dstUri.empty() ? store : openStore(dstUri); std::string copiedLabel = "copied"; diff --git a/src/nix/sigs.cc b/src/nix/sigs.cc index 9932aa4a9..0c0d7b728 100644 --- a/src/nix/sigs.cc +++ b/src/nix/sigs.cc @@ -35,7 +35,7 @@ struct CmdCopySigs : StorePathsCommand // FIXME: factor out commonality with MixVerify. std::vector> substituters; for (auto & s : substituterUris) - substituters.push_back(openStoreAt(s)); + substituters.push_back(openStore(s)); ThreadPool pool; diff --git a/src/nix/verify.cc b/src/nix/verify.cc index f2b6acdfb..519fcb6f8 100644 --- a/src/nix/verify.cc +++ b/src/nix/verify.cc @@ -52,7 +52,7 @@ struct CmdVerify : StorePathsCommand { std::vector> substituters; for (auto & s : substituterUris) - substituters.push_back(openStoreAt(s)); + substituters.push_back(openStore(s)); auto publicKeys = getDefaultPublicKeys();