Support Nix 2.17

This commit is contained in:
Linus Heckemann 2023-08-04 15:53:06 +02:00
parent 60e2c377d3
commit b23431a657
3 changed files with 20 additions and 15 deletions

View file

@ -42,16 +42,16 @@
"nixpkgs-regression": "nixpkgs-regression" "nixpkgs-regression": "nixpkgs-regression"
}, },
"locked": { "locked": {
"lastModified": 1686048923, "lastModified": 1690219894,
"narHash": "sha256-/XCWa2osNFIpPC5MkxlX6qTZf/DaTLwS3LWN0SRFiuU=", "narHash": "sha256-QMYAkdtU+g9HlZKtoJ+AI6TbWzzovKGnPZJHfZdclc8=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nix", "repo": "nix",
"rev": "84050709ea18f3285a85d729f40c8f8eddf5008e", "rev": "a212300a1d9f9c7b0daf19c00c87fc50480f54f4",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "2.16.1", "ref": "2.17.0",
"repo": "nix", "repo": "nix",
"type": "github" "type": "github"
} }

View file

@ -2,7 +2,7 @@
description = "A Nix-based continuous build system"; description = "A Nix-based continuous build system";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
inputs.nix.url = "github:NixOS/nix/2.16.1"; inputs.nix.url = "github:NixOS/nix/2.17.0";
inputs.nix.inputs.nixpkgs.follows = "nixpkgs"; inputs.nix.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, nix }: outputs = { self, nixpkgs, nix }:

View file

@ -6,6 +6,7 @@
#include <fcntl.h> #include <fcntl.h>
#include "build-result.hh" #include "build-result.hh"
#include "path.hh"
#include "serve-protocol.hh" #include "serve-protocol.hh"
#include "state.hh" #include "state.hh"
#include "util.hh" #include "util.hh"
@ -110,18 +111,20 @@ static void copyClosureTo(std::timed_mutex & sendMutex, Store & destStore,
StorePathSet closure; StorePathSet closure;
destStore.computeFSClosure(paths, closure); destStore.computeFSClosure(paths, closure);
WorkerProto::WriteConn wconn { .to = to };
WorkerProto::ReadConn rconn { .from = from };
/* Send the "query valid paths" command with the "lock" option /* Send the "query valid paths" command with the "lock" option
enabled. This prevents a race where the remote host enabled. This prevents a race where the remote host
garbage-collect paths that are already there. Optionally, ask garbage-collect paths that are already there. Optionally, ask
the remote host to substitute missing paths. */ the remote host to substitute missing paths. */
// FIXME: substitute output pollutes our build log // FIXME: substitute output pollutes our build log
to << cmdQueryValidPaths << 1 << useSubstitutes; to << ServeProto::Command::QueryValidPaths << 1 << useSubstitutes;
workerProtoWrite(destStore, to, closure); WorkerProto::write(destStore, wconn, closure);
to.flush(); to.flush();
/* Get back the set of paths that are already valid on the remote /* Get back the set of paths that are already valid on the remote
host. */ host. */
auto present = WorkerProto<StorePathSet>::read(destStore, from); auto present = WorkerProto::Serialise<StorePathSet>::read(destStore, rconn);
if (present.size() == closure.size()) return; if (present.size() == closure.size()) return;
@ -136,7 +139,7 @@ static void copyClosureTo(std::timed_mutex & sendMutex, Store & destStore,
std::unique_lock<std::timed_mutex> sendLock(sendMutex, std::unique_lock<std::timed_mutex> sendLock(sendMutex,
std::chrono::seconds(600)); std::chrono::seconds(600));
to << cmdImportPaths; to << ServeProto::Command::ImportPaths;
destStore.exportPaths(missing, to); destStore.exportPaths(missing, to);
to.flush(); to.flush();
@ -223,7 +226,9 @@ void State::buildRemote(ref<Store> destStore,
}); });
FdSource from(child.from.get()); FdSource from(child.from.get());
WorkerProto::ReadConn rconn { .from = from };
FdSink to(child.to.get()); FdSink to(child.to.get());
WorkerProto::WriteConn wconn { .to = to };
Finally updateStats([&]() { Finally updateStats([&]() {
bytesReceived += from.read; bytesReceived += from.read;
@ -334,7 +339,7 @@ void State::buildRemote(ref<Store> destStore,
updateStep(ssBuilding); updateStep(ssBuilding);
to << cmdBuildDerivation << localStore->printStorePath(step->drvPath); to << ServeProto::Command::BuildDerivation << localStore->printStorePath(step->drvPath);
writeDerivation(to, *localStore, basicDrv); writeDerivation(to, *localStore, basicDrv);
to << maxSilentTime << buildTimeout; to << maxSilentTime << buildTimeout;
if (GET_PROTOCOL_MINOR(remoteVersion) >= 2) if (GET_PROTOCOL_MINOR(remoteVersion) >= 2)
@ -367,7 +372,7 @@ void State::buildRemote(ref<Store> destStore,
} }
} }
if (GET_PROTOCOL_MINOR(remoteVersion) >= 6) { if (GET_PROTOCOL_MINOR(remoteVersion) >= 6) {
WorkerProto<DrvOutputs>::read(*localStore, from); WorkerProto::Serialise<DrvOutputs>::read(*localStore, rconn);
} }
switch ((BuildResult::Status) res) { switch ((BuildResult::Status) res) {
case BuildResult::Built: case BuildResult::Built:
@ -443,14 +448,14 @@ void State::buildRemote(ref<Store> destStore,
/* Get info about each output path. */ /* Get info about each output path. */
std::map<StorePath, ValidPathInfo> infos; std::map<StorePath, ValidPathInfo> infos;
size_t totalNarSize = 0; size_t totalNarSize = 0;
to << cmdQueryPathInfos; to << ServeProto::Command::QueryPathInfos;
workerProtoWrite(*localStore, to, outputs); WorkerProto::write(*localStore, wconn, outputs);
to.flush(); to.flush();
while (true) { while (true) {
auto storePathS = readString(from); auto storePathS = readString(from);
if (storePathS == "") break; if (storePathS == "") break;
auto deriver = readString(from); // deriver auto deriver = readString(from); // deriver
auto references = WorkerProto<StorePathSet>::read(*localStore, from); auto references = WorkerProto::Serialise<StorePathSet>::read(*localStore, rconn);
readLongLong(from); // download size readLongLong(from); // download size
auto narSize = readLongLong(from); auto narSize = readLongLong(from);
auto narHash = Hash::parseAny(readString(from), htSHA256); auto narHash = Hash::parseAny(readString(from), htSHA256);
@ -494,7 +499,7 @@ void State::buildRemote(ref<Store> destStore,
lambda function only gets executed if someone tries to read lambda function only gets executed if someone tries to read
from source2, we will send the command from here rather from source2, we will send the command from here rather
than outside the lambda. */ than outside the lambda. */
to << cmdDumpStorePath << localStore->printStorePath(path); to << ServeProto::Command::DumpStorePath << localStore->printStorePath(path);
to.flush(); to.flush();
TeeSource tee(from, sink); TeeSource tee(from, sink);