diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/build.cc | 2 | ||||
-rw-r--r-- | src/libstore/gc.cc | 2 | ||||
-rw-r--r-- | src/libstore/local-store.cc | 10 | ||||
-rw-r--r-- | src/libstore/local-store.hh | 6 | ||||
-rw-r--r-- | src/libstore/remote-store.cc | 18 | ||||
-rw-r--r-- | src/libstore/remote-store.hh | 2 | ||||
-rw-r--r-- | src/libstore/store-api.hh | 4 | ||||
-rw-r--r-- | src/libstore/worker-protocol.hh | 1 | ||||
-rw-r--r-- | src/nix-store/nix-store.cc | 4 | ||||
-rw-r--r-- | src/nix-worker/nix-worker.cc | 9 |
10 files changed, 42 insertions, 16 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 5c8b31cf6a6b..e300292e96cf 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1065,7 +1065,7 @@ static string makeValidityRegistration(const PathSet & paths, for (PathSet::iterator i = paths.begin(); i != paths.end(); ++i) { s += *i + "\n"; - Path deriver = showDerivers ? queryDeriver(noTxn, *i) : ""; + Path deriver = showDerivers ? store->queryDeriver(*i) : ""; s += deriver + "\n"; PathSet references; diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index 2ad52d8bf4ea..3699b234402f 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -482,7 +482,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete, /* Note that the deriver need not be valid (e.g., if we previously ran the collector with `gcKeepDerivations' turned off). */ - Path deriver = queryDeriver(noTxn, *i); + Path deriver = store->queryDeriver(*i); if (deriver != "" && store->isValidPath(deriver)) computeFSClosure(deriver, livePaths); } diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index cd8bc1a3394f..1165335125b9 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -399,7 +399,7 @@ void setDeriver(const Transaction & txn, const Path & storePath, } -Path queryDeriver(const Transaction & txn, const Path & storePath) +static Path queryDeriver(const Transaction & txn, const Path & storePath) { if (!isRealisablePath(txn, storePath)) throw Error(format("path `%1%' is not valid") % storePath); @@ -411,6 +411,12 @@ Path queryDeriver(const Transaction & txn, const Path & storePath) } +Path LocalStore::queryDeriver(const Path & path) +{ + return nix::queryDeriver(noTxn, path); +} + + const int substituteVersion = 2; @@ -756,7 +762,7 @@ void LocalStore::exportPath(const Path & path, bool sign, nix::queryReferences(txn, path, references); writeStringSet(references, hashAndWriteSink); - Path deriver = queryDeriver(txn, path); + Path deriver = nix::queryDeriver(txn, path); writeString(deriver, hashAndWriteSink); if (sign) { diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index 099be2efcd1a..7c5cd2668405 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -49,6 +49,8 @@ public: void queryReferrers(const Path & path, PathSet & referrers); + Path queryDeriver(const Path & path); + Path addToStore(const Path & srcPath, bool fixed = false, bool recursive = false, string hashAlgo = "", PathFilter & filter = defaultPathFilter); @@ -136,10 +138,6 @@ void setReferences(const Transaction & txn, const Path & path, void setDeriver(const Transaction & txn, const Path & path, const Path & deriver); -/* Query the deriver of a store path. Return the empty string if no - deriver has been set. */ -Path queryDeriver(const Transaction & txn, const Path & path); - /* Delete a value from the nixStore directory. */ void deleteFromStore(const Path & path, unsigned long long & bytesFreed); diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 449a4c448f0f..820bf66ad99a 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -212,6 +212,15 @@ void RemoteStore::queryReferrers(const Path & path, } +Path RemoteStore::queryDeriver(const Path & path) +{ + writeInt(wopQueryDeriver, to); + writeString(path, to); + processStderr(); + return readStorePath(from); +} + + Path RemoteStore::addToStore(const Path & _srcPath, bool fixed, bool recursive, string hashAlgo, PathFilter & filter) { @@ -224,8 +233,7 @@ Path RemoteStore::addToStore(const Path & _srcPath, bool fixed, writeString(hashAlgo, to); dumpPath(srcPath, to, filter); processStderr(); - Path path = readStorePath(from); - return path; + return readStorePath(from); } @@ -238,8 +246,7 @@ Path RemoteStore::addTextToStore(const string & suffix, const string & s, writeStringSet(references, to); processStderr(); - Path path = readStorePath(from); - return path; + return readStorePath(from); } @@ -261,8 +268,7 @@ Path RemoteStore::importPath(bool requireSignature, Source & source) anyway. */ processStderr(0, &source); - Path path = readStorePath(from); - return path; + return readStorePath(from); } diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh index 19af8c0bed7f..29b4a88f9a4b 100644 --- a/src/libstore/remote-store.hh +++ b/src/libstore/remote-store.hh @@ -37,6 +37,8 @@ public: void queryReferrers(const Path & path, PathSet & referrers); + Path queryDeriver(const Path & path); + Path addToStore(const Path & srcPath, bool fixed = false, bool recursive = false, string hashAlgo = "", PathFilter & filter = defaultPathFilter); diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 8531eb040496..01b561e9d496 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -77,6 +77,10 @@ public: virtual void queryReferrers(const Path & path, PathSet & referrers) = 0; + /* Query the deriver of a store path. Return the empty string if + no deriver has been set. */ + virtual Path queryDeriver(const Path & path) = 0; + /* Copy the contents of a path to the store and register the validity the resulting path. The resulting path is returned. If `fixed' is true, then the output of a fixed-output diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh index 0126c8d59db9..4a2e8b6942cf 100644 --- a/src/libstore/worker-protocol.hh +++ b/src/libstore/worker-protocol.hh @@ -28,6 +28,7 @@ typedef enum { wopCollectGarbage, wopExportPath, wopImportPath, + wopQueryDeriver, } WorkerOp; diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index 88acc79aa162..c600a5b9a7dc 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -46,7 +46,7 @@ static Path fixPath(Path path) static Path useDeriver(Path path) { if (!isDerivation(path)) { - path = queryDeriver(noTxn, path); + path = store->queryDeriver(path); if (path == "") throw Error(format("deriver of path `%1%' is not known") % path); } @@ -330,7 +330,7 @@ static void opQuery(Strings opFlags, Strings opArgs) for (Strings::iterator i = opArgs.begin(); i != opArgs.end(); ++i) { - Path deriver = queryDeriver(noTxn, fixPath(*i)); + Path deriver = store->queryDeriver(fixPath(*i)); cout << format("%1%\n") % (deriver == "" ? "unknown-deriver" : deriver); } diff --git a/src/nix-worker/nix-worker.cc b/src/nix-worker/nix-worker.cc index 078362e9c37b..6ddf01bd017d 100644 --- a/src/nix-worker/nix-worker.cc +++ b/src/nix-worker/nix-worker.cc @@ -277,6 +277,15 @@ static void performOp(Source & from, Sink & to, unsigned int op) break; } + case wopQueryDeriver: { + Path path = readStorePath(from); + startWork(); + Path deriver = store->queryDeriver(path); + stopWork(); + writeString(deriver, to); + break; + } + case wopAddToStore: { /* !!! uberquick hack */ string baseName = readString(from); |