From 2387d676393cf12185716b0c188beb5a8c1cb5a8 Mon Sep 17 00:00:00 2001 From: DavHau Date: Sun, 8 Oct 2023 11:22:13 +0200 Subject: [PATCH] align `system` retrieval with `nix-build` Read the system from the instantiated derivation instead of getting it from the eval time drv attrs. This is better in terms of correctness as it derives the system through a derivations string context, instead of relying on builder implementations to set the `system` attribute correctly. This derivation for example did not build with hydra before while it builds fine with the nix repl: ``` :b { name="hello"; type="derivation"; drvPath = hello.drvPath; } ``` --- src/hydra-eval-jobs/hydra-eval-jobs.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hydra-eval-jobs/hydra-eval-jobs.cc b/src/hydra-eval-jobs/hydra-eval-jobs.cc index 79523944c..b883bedf5 100644 --- a/src/hydra-eval-jobs/hydra-eval-jobs.cc +++ b/src/hydra-eval-jobs/hydra-eval-jobs.cc @@ -177,15 +177,14 @@ static void worker( DrvInfo::Outputs outputs = drv->queryOutputs(); - if (drv->querySystem() == "unknown") - throw EvalError("derivation must have a 'system' attribute"); + auto drvContent = state.store->readDerivation(drv->requireDrvPath()); auto drvPath = state.store->printStorePath(drv->requireDrvPath()); nlohmann::json job; job["nixName"] = drv->queryName(); - job["system"] =drv->querySystem(); + job["system"] = drvContent.platform; job["drvPath"] = drvPath; job["description"] = drv->queryMetaString("description"); job["license"] = queryMetaStrings(state, *drv, "license", "shortName");