Skip to content

Commit

Permalink
Merge pull request #1296 from DeterminateSystems/nix-2.17
Browse files Browse the repository at this point in the history
Support Nix 2.17
  • Loading branch information
edolstra authored Aug 23, 2023
2 parents 60e2c37 + 35ccc9e commit 00d3087
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "A Nix-based continuous build system";

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";

outputs = { self, nixpkgs, nix }:
Expand Down
26 changes: 16 additions & 10 deletions src/hydra-queue-runner/build-remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
#include <fcntl.h>

#include "build-result.hh"
#include "path.hh"
#include "serve-protocol.hh"
#include "state.hh"
#include "util.hh"
#include "worker-protocol.hh"
#include "worker-protocol-impl.hh"
#include "finally.hh"
#include "url.hh"

Expand Down Expand Up @@ -110,18 +112,20 @@ static void copyClosureTo(std::timed_mutex & sendMutex, Store & destStore,
StorePathSet 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
enabled. This prevents a race where the remote host
garbage-collect paths that are already there. Optionally, ask
the remote host to substitute missing paths. */
// FIXME: substitute output pollutes our build log
to << cmdQueryValidPaths << 1 << useSubstitutes;
workerProtoWrite(destStore, to, closure);
to << ServeProto::Command::QueryValidPaths << 1 << useSubstitutes;
WorkerProto::write(destStore, wconn, closure);
to.flush();

/* Get back the set of paths that are already valid on the remote
host. */
auto present = WorkerProto<StorePathSet>::read(destStore, from);
auto present = WorkerProto::Serialise<StorePathSet>::read(destStore, rconn);

if (present.size() == closure.size()) return;

Expand All @@ -136,7 +140,7 @@ static void copyClosureTo(std::timed_mutex & sendMutex, Store & destStore,
std::unique_lock<std::timed_mutex> sendLock(sendMutex,
std::chrono::seconds(600));

to << cmdImportPaths;
to << ServeProto::Command::ImportPaths;
destStore.exportPaths(missing, to);
to.flush();

Expand Down Expand Up @@ -223,7 +227,9 @@ void State::buildRemote(ref<Store> destStore,
});

FdSource from(child.from.get());
WorkerProto::ReadConn rconn { .from = from };
FdSink to(child.to.get());
WorkerProto::WriteConn wconn { .to = to };

Finally updateStats([&]() {
bytesReceived += from.read;
Expand Down Expand Up @@ -334,7 +340,7 @@ void State::buildRemote(ref<Store> destStore,

updateStep(ssBuilding);

to << cmdBuildDerivation << localStore->printStorePath(step->drvPath);
to << ServeProto::Command::BuildDerivation << localStore->printStorePath(step->drvPath);
writeDerivation(to, *localStore, basicDrv);
to << maxSilentTime << buildTimeout;
if (GET_PROTOCOL_MINOR(remoteVersion) >= 2)
Expand Down Expand Up @@ -367,7 +373,7 @@ void State::buildRemote(ref<Store> destStore,
}
}
if (GET_PROTOCOL_MINOR(remoteVersion) >= 6) {
WorkerProto<DrvOutputs>::read(*localStore, from);
WorkerProto::Serialise<DrvOutputs>::read(*localStore, rconn);
}
switch ((BuildResult::Status) res) {
case BuildResult::Built:
Expand Down Expand Up @@ -443,14 +449,14 @@ void State::buildRemote(ref<Store> destStore,
/* Get info about each output path. */
std::map<StorePath, ValidPathInfo> infos;
size_t totalNarSize = 0;
to << cmdQueryPathInfos;
workerProtoWrite(*localStore, to, outputs);
to << ServeProto::Command::QueryPathInfos;
WorkerProto::write(*localStore, wconn, outputs);
to.flush();
while (true) {
auto storePathS = readString(from);
if (storePathS == "") break;
auto deriver = readString(from); // deriver
auto references = WorkerProto<StorePathSet>::read(*localStore, from);
auto references = WorkerProto::Serialise<StorePathSet>::read(*localStore, rconn);
readLongLong(from); // download size
auto narSize = readLongLong(from);
auto narHash = Hash::parseAny(readString(from), htSHA256);
Expand Down Expand Up @@ -494,7 +500,7 @@ void State::buildRemote(ref<Store> destStore,
lambda function only gets executed if someone tries to read
from source2, we will send the command from here rather
than outside the lambda. */
to << cmdDumpStorePath << localStore->printStorePath(path);
to << ServeProto::Command::DumpStorePath << localStore->printStorePath(path);
to.flush();

TeeSource tee(from, sink);
Expand Down

0 comments on commit 00d3087

Please sign in to comment.