Merge pull request #15 from nix-community/json

also expose store path in json
This commit is contained in:
Jörg Thalheim 2021-12-31 12:58:52 +00:00 committed by GitHub
commit 77aa769aef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -171,10 +171,13 @@ static void worker(
throw EvalError("derivation must have a 'system' attribute");
auto drvPath = drv->queryDrvPath();
auto localStore = state.store.dynamic_pointer_cast<LocalFSStore>();
auto storePath = localStore->parseStorePath(drvPath);
reply["name"] = drv->queryName();
reply["system"] = drv->querySystem();
reply["drvPath"] = drvPath;
reply["storePath"] = localStore->printStorePath(storePath);
nlohmann::json meta;
for (auto & name : drv->queryMetaNames()) {
@ -196,9 +199,7 @@ static void worker(
/* Register the derivation as a GC root. !!! This
registers roots for jobs that we may have already
done. */
auto localStore = state.store.dynamic_pointer_cast<LocalFSStore>();
auto storePath = localStore->parseStorePath(drvPath);
if (gcRootsDir != "" && localStore) {
if (gcRootsDir != "") {
Path root = gcRootsDir + "/" + std::string(baseNameOf(drvPath));
if (!pathExists(root))
localStore->addPermRoot(storePath, root);

View file

@ -28,6 +28,8 @@ def common_test(extra_args: List[str]) -> None:
built_job = results[0]
assert built_job["attr"] == "builtJob"
assert built_job["name"] == "job1"
assert built_job["storePath"].startswith("/nix/store")
assert built_job["drvPath"].endswith(".drv")
substituted_job = results[1]