aboutsummaryrefslogtreecommitdiff
path: root/src/nix-store/nix-store.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix-store/nix-store.cc')
-rw-r--r--src/nix-store/nix-store.cc35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 24a488d43..ad14ba9db 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -2,6 +2,8 @@
#include "derivations.hh"
#include "dotgraph.hh"
#include "globals.hh"
+#include "build-result.hh"
+#include "gc-store.hh"
#include "local-store.hh"
#include "monitor-fd.hh"
#include "serve-protocol.hh"
@@ -208,8 +210,8 @@ static void opPrintFixedPath(Strings opFlags, Strings opArgs)
Strings::iterator i = opArgs.begin();
HashType hashAlgo = parseHashType(*i++);
- string hash = *i++;
- string name = *i++;
+ std::string hash = *i++;
+ std::string name = *i++;
cout << fmt("%s\n", store->printStorePath(store->makeFixedOutputPath(name, FixedOutputInfo {
{
@@ -244,7 +246,7 @@ static StorePathSet maybeUseOutputs(const StorePath & storePath, bool useOutput,
graph. Topological sorting is used to keep the tree relatively
flat. */
static void printTree(const StorePath & path,
- const string & firstPad, const string & tailPad, StorePathSet & done)
+ const std::string & firstPad, const std::string & tailPad, StorePathSet & done)
{
if (!done.insert(path).second) {
cout << fmt("%s%s [...]\n", firstPad, store->printStorePath(path));
@@ -283,7 +285,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
bool useOutput = false;
bool includeOutputs = false;
bool forceRealise = false;
- string bindingName;
+ std::string bindingName;
for (auto & i : opFlags) {
QueryType prev = query;
@@ -433,11 +435,12 @@ static void opQuery(Strings opFlags, Strings opArgs)
store->computeFSClosure(
args, referrers, true, settings.gcKeepOutputs, settings.gcKeepDerivations);
- Roots roots = store->findRoots(false);
+ auto & gcStore = requireGcStore(*store);
+ Roots roots = gcStore.findRoots(false);
for (auto & [target, links] : roots)
if (referrers.find(target) != referrers.end())
for (auto & link : links)
- cout << fmt("%1% -> %2%\n", link, store->printStorePath(target));
+ cout << fmt("%1% -> %2%\n", link, gcStore.printStorePath(target));
break;
}
@@ -593,20 +596,22 @@ static void opGC(Strings opFlags, Strings opArgs)
if (!opArgs.empty()) throw UsageError("no arguments expected");
+ auto & gcStore = requireGcStore(*store);
+
if (printRoots) {
- Roots roots = store->findRoots(false);
+ Roots roots = gcStore.findRoots(false);
std::set<std::pair<Path, StorePath>> roots2;
// Transpose and sort the roots.
for (auto & [target, links] : roots)
for (auto & link : links)
roots2.emplace(link, target);
for (auto & [link, target] : roots2)
- std::cout << link << " -> " << store->printStorePath(target) << "\n";
+ std::cout << link << " -> " << gcStore.printStorePath(target) << "\n";
}
else {
PrintFreed freed(options.action == GCOptions::gcDeleteDead, results);
- store->collectGarbage(options, results);
+ gcStore.collectGarbage(options, results);
if (options.action != GCOptions::gcDeleteDead)
for (auto & i : results.paths)
@@ -630,9 +635,11 @@ static void opDelete(Strings opFlags, Strings opArgs)
for (auto & i : opArgs)
options.pathsToDelete.insert(store->followLinksToStorePath(i));
+ auto & gcStore = requireGcStore(*store);
+
GCResults results;
PrintFreed freed(true, results);
- store->collectGarbage(options, results);
+ gcStore.collectGarbage(options, results);
}
@@ -643,7 +650,7 @@ static void opDump(Strings opFlags, Strings opArgs)
if (opArgs.size() != 1) throw UsageError("only one argument allowed");
FdSink sink(STDOUT_FILENO);
- string path = *opArgs.begin();
+ std::string path = *opArgs.begin();
dumpPath(path, sink);
sink.flush();
}
@@ -981,9 +988,9 @@ static void opGenerateBinaryCacheKey(Strings opFlags, Strings opArgs)
if (opArgs.size() != 3) throw UsageError("three arguments expected");
auto i = opArgs.begin();
- string keyName = *i++;
- string secretKeyFile = *i++;
- string publicKeyFile = *i++;
+ std::string keyName = *i++;
+ std::string secretKeyFile = *i++;
+ std::string publicKeyFile = *i++;
auto secretKey = SecretKey::generate(keyName);