diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-06-02 13:33:49 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-06-02 16:02:48 +0200 |
commit | 812c0dfbe24c8fe93992f77abbf1e5a975ea42f4 (patch) | |
tree | d69bcc87ce446f270f6b01f7069655223d52a626 /src/nix-store | |
parent | f2682e6e18a76ecbfb8a12c17e3a0ca15c084197 (diff) |
Allow setting the state directory as a store parameter
E.g. "local?store=/tmp/store&state=/tmp/var".
Diffstat (limited to 'src/nix-store')
-rw-r--r-- | src/nix-store/nix-store.cc | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index cd00412a8..78b2aa102 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<LocalFSStore>(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}; } |