From 812c0dfbe24c8fe93992f77abbf1e5a975ea42f4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 2 Jun 2016 13:33:49 +0200 Subject: Allow setting the state directory as a store parameter E.g. "local?store=/tmp/store&state=/tmp/var". --- src/nix-store/nix-store.cc | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src/nix-store') diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index cd00412a8a86..78b2aa102714 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -63,6 +63,8 @@ static PathSet realisePath(Path path, bool build = true) { DrvPathWithOutputs p = parseDrvPathWithOutputs(path); + auto store2 = std::dynamic_pointer_cast(store); + if (isDerivation(p.first)) { if (build) store->buildPaths({path}); Derivation drv = store->derivationFromPath(p.first); @@ -77,13 +79,15 @@ static PathSet realisePath(Path path, bool build = true) if (i == drv.outputs.end()) throw Error(format("derivation ‘%1%’ does not have an output named ‘%2%’") % p.first % j); Path outPath = i->second.path; - if (gcRoot == "") - printGCWarning(); - else { - Path rootName = gcRoot; - if (rootNr > 1) rootName += "-" + std::to_string(rootNr); - if (i->first != "out") rootName += "-" + i->first; - outPath = store->addPermRoot(outPath, rootName, indirectRoot); + if (store2) { + if (gcRoot == "") + printGCWarning(); + else { + Path rootName = gcRoot; + if (rootNr > 1) rootName += "-" + std::to_string(rootNr); + if (i->first != "out") rootName += "-" + i->first; + outPath = store2->addPermRoot(outPath, rootName, indirectRoot); + } } outputs.insert(outPath); } @@ -93,13 +97,15 @@ static PathSet realisePath(Path path, bool build = true) else { if (build) store->ensurePath(path); else if (!store->isValidPath(path)) throw Error(format("path ‘%1%’ does not exist and cannot be created") % path); - if (gcRoot == "") - printGCWarning(); - else { - Path rootName = gcRoot; - rootNr++; - if (rootNr > 1) rootName += "-" + std::to_string(rootNr); - path = store->addPermRoot(path, rootName, indirectRoot); + if (store2) { + if (gcRoot == "") + printGCWarning(); + else { + Path rootName = gcRoot; + rootNr++; + if (rootNr > 1) rootName += "-" + std::to_string(rootNr); + path = store2->addPermRoot(path, rootName, indirectRoot); + } } return {path}; } -- cgit 1.4.1