From 9ebc15e7093539939616981962da0c072847d7ce Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 15 Oct 2025 14:48:41 -0400 Subject: [PATCH] Upgrade Nix to 2.32 --- flake.lock | 16 +-- flake.nix | 4 +- src/hydra-queue-runner/build-remote.cc | 158 ++++++++++++++----------- 3 files changed, 99 insertions(+), 79 deletions(-) diff --git a/flake.lock b/flake.lock index e0c89e67..63897d26 100644 --- a/flake.lock +++ b/flake.lock @@ -3,16 +3,16 @@ "nix": { "flake": false, "locked": { - "lastModified": 1759956402, - "narHash": "sha256-CM27YK+KMi3HLRXqjPaJwkTabmKW+CDXOE3kMMtXH3s=", + "lastModified": 1760573252, + "narHash": "sha256-mcvNeNdJP5R7huOc8Neg0qZESx/0DMg8Fq6lsdx0x8U=", "owner": "NixOS", "repo": "nix", - "rev": "3019db2c87006817b6201113ad4ceee0c53c3b62", + "rev": "3c39583e5512729f9c5a44c3b03b6467a2acd963", "type": "github" }, "original": { "owner": "NixOS", - "ref": "2.31-maintenance", + "ref": "2.32-maintenance", "repo": "nix", "type": "github" } @@ -20,16 +20,16 @@ "nix-eval-jobs": { "flake": false, "locked": { - "lastModified": 1757626891, - "narHash": "sha256-VrHPtHxVIboqgnw+tlCQepgtBOhBvU5hxbMHsPo8LAc=", + "lastModified": 1760478325, + "narHash": "sha256-hA+NOH8KDcsuvH7vJqSwk74PyZP3MtvI/l+CggZcnTc=", "owner": "nix-community", "repo": "nix-eval-jobs", - "rev": "c975efc5b2bec0c1ff93c67de4a03306af258ff7", + "rev": "daa42f9e9c84aeff1e325dd50fda321f53dfd02c", "type": "github" }, "original": { "owner": "nix-community", - "ref": "v2.31.0", + "ref": "v2.32.1", "repo": "nix-eval-jobs", "type": "github" } diff --git a/flake.nix b/flake.nix index 7d443970..703a76f4 100644 --- a/flake.nix +++ b/flake.nix @@ -4,13 +4,13 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05-small"; inputs.nix = { - url = "github:NixOS/nix/2.31-maintenance"; + url = "github:NixOS/nix/2.32-maintenance"; # We want to control the deps precisely flake = false; }; inputs.nix-eval-jobs = { - url = "github:nix-community/nix-eval-jobs/v2.31.0"; + url = "github:nix-community/nix-eval-jobs/v2.32.1"; # We want to control the deps precisely flake = false; }; diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc index c0d6ff6c..1489f7d6 100644 --- a/src/hydra-queue-runner/build-remote.cc +++ b/src/hydra-queue-runner/build-remote.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -104,7 +105,7 @@ static void copyClosureTo( std::chrono::seconds(600)); conn.importPaths(destStore, [&](Sink & sink) { - destStore.exportPaths(missing, sink); + exportPaths(destStore, missing, sink); }); if (readInt(conn.from) != 1) @@ -262,16 +263,18 @@ static BuildResult performBuild( // Since this a `BasicDerivation`, `staticOutputHashes` will not // do any real work. auto outputHashes = staticOutputHashes(localStore, drv); - for (auto & [outputName, output] : drvOutputs) { - auto outputPath = output.second; - // We’ve just asserted that the output paths of the derivation - // were known - assert(outputPath); - auto outputHash = outputHashes.at(outputName); - auto drvOutput = DrvOutput { outputHash, outputName }; - result.builtOutputs.insert_or_assign( - std::move(outputName), - Realisation { drvOutput, *outputPath }); + if (auto * successP = result.tryGetSuccess()) { + for (auto & [outputName, output] : drvOutputs) { + auto outputPath = output.second; + // We’ve just asserted that the output paths of the derivation + // were known + assert(outputPath); + auto outputHash = outputHashes.at(outputName); + auto drvOutput = DrvOutput { outputHash, outputName }; + successP->builtOutputs.insert_or_assign( + std::move(outputName), + Realisation { drvOutput, *outputPath }); + } } } @@ -335,54 +338,68 @@ void RemoteResult::updateWithBuildResult(const nix::BuildResult & buildResult) startTime = buildResult.startTime; stopTime = buildResult.stopTime; timesBuilt = buildResult.timesBuilt; - errorMsg = buildResult.errorMsg; - isNonDeterministic = buildResult.isNonDeterministic; - switch ((BuildResult::Status) buildResult.status) { - case BuildResult::Built: + std::visit(overloaded{ + [&](const BuildResult::Success & success) { stepStatus = bsSuccess; - break; - case BuildResult::Substituted: - case BuildResult::AlreadyValid: - stepStatus = bsSuccess; - isCached = true; - break; - case BuildResult::PermanentFailure: - stepStatus = bsFailed; - canCache = true; - errorMsg = ""; - break; - case BuildResult::InputRejected: - case BuildResult::OutputRejected: - stepStatus = bsFailed; - canCache = true; - break; - case BuildResult::TransientFailure: - stepStatus = bsFailed; - canRetry = true; - errorMsg = ""; - break; - case BuildResult::TimedOut: - stepStatus = bsTimedOut; - errorMsg = ""; - break; - case BuildResult::MiscFailure: - stepStatus = bsAborted; - canRetry = true; - break; - case BuildResult::LogLimitExceeded: - stepStatus = bsLogLimitExceeded; - break; - case BuildResult::NotDeterministic: - stepStatus = bsNotDeterministic; - canRetry = false; - canCache = true; - break; - default: - stepStatus = bsAborted; - break; - } - + switch (success.status) { + case BuildResult::Success::Built: + break; + case BuildResult::Success::Substituted: + case BuildResult::Success::AlreadyValid: + case BuildResult::Success::ResolvesToAlreadyValid: + isCached = true; + break; + default: + assert(false); + } + }, + [&](const BuildResult::Failure & failure) { + errorMsg = failure.errorMsg; + isNonDeterministic = failure.isNonDeterministic; + switch (failure.status) { + case BuildResult::Failure::PermanentFailure: + stepStatus = bsFailed; + canCache = true; + errorMsg = ""; + break; + case BuildResult::Failure::InputRejected: + case BuildResult::Failure::OutputRejected: + stepStatus = bsFailed; + canCache = true; + break; + case BuildResult::Failure::TransientFailure: + stepStatus = bsFailed; + canRetry = true; + errorMsg = ""; + break; + case BuildResult::Failure::TimedOut: + stepStatus = bsTimedOut; + errorMsg = ""; + break; + case BuildResult::Failure::MiscFailure: + stepStatus = bsAborted; + canRetry = true; + break; + case BuildResult::Failure::LogLimitExceeded: + stepStatus = bsLogLimitExceeded; + break; + case BuildResult::Failure::NotDeterministic: + stepStatus = bsNotDeterministic; + canRetry = false; + canCache = true; + break; + case BuildResult::Failure::CachedFailure: + case BuildResult::Failure::DependencyFailed: + case BuildResult::Failure::NoSubstituters: + case BuildResult::Failure::HashMismatch: + stepStatus = bsAborted; + break; + default: + assert(false); + } + }, + }, buildResult.inner); } /* Utility guard object to auto-release a semaphore on destruction. */ @@ -404,7 +421,7 @@ void State::buildRemote(ref destStore, std::function updateStep, NarMemberDatas & narMembers) { - assert(BuildResult::TimedOut == 8); + assert(BuildResult::Failure::TimedOut == 8); auto [logFile, logFD] = build_remote::openLogFile(logDir, step->drvPath); AutoDelete logFileDel(logFile, false); @@ -513,7 +530,7 @@ void State::buildRemote(ref destStore, updateStep(ssBuilding); - BuildResult buildResult = build_remote::performBuild( + auto buildResult = build_remote::performBuild( conn, *localStore, step->drvPath, @@ -555,8 +572,9 @@ void State::buildRemote(ref destStore, wakeDispatcher(); StorePathSet outputs; - for (auto & [_, realisation] : buildResult.builtOutputs) - outputs.insert(realisation.outPath); + if (auto * successP = buildResult.tryGetSuccess()) + for (auto & [_, realisation] : successP->builtOutputs) + outputs.insert(realisation.outPath); /* Copy the output paths. */ if (!machine->isLocalhost() || localStore != std::shared_ptr(destStore)) { @@ -589,15 +607,17 @@ void State::buildRemote(ref destStore, /* Register the outputs of the newly built drv */ if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) { auto outputHashes = staticOutputHashes(*localStore, *step->drv); - for (auto & [outputName, realisation] : buildResult.builtOutputs) { - // Register the resolved drv output - destStore->registerDrvOutput(realisation); + if (auto * successP = buildResult.tryGetSuccess()) { + for (auto & [outputName, realisation] : successP->builtOutputs) { + // Register the resolved drv output + destStore->registerDrvOutput(realisation); - // Also register the unresolved one - auto unresolvedRealisation = realisation; - unresolvedRealisation.signatures.clear(); - unresolvedRealisation.id.drvHash = outputHashes.at(outputName); - destStore->registerDrvOutput(unresolvedRealisation); + // Also register the unresolved one + auto unresolvedRealisation = realisation; + unresolvedRealisation.signatures.clear(); + unresolvedRealisation.id.drvHash = outputHashes.at(outputName); + destStore->registerDrvOutput(unresolvedRealisation); + } } }