Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Nix 2.19 #1314

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.18.1";
inputs.nix.url = "github:NixOS/nix/2.19.2";
inputs.nix.inputs.nixpkgs.follows = "nixpkgs";

outputs = { self, nixpkgs, nix }:
Expand Down
8 changes: 5 additions & 3 deletions src/hydra-eval-jobs/hydra-eval-jobs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "eval.hh"
#include "eval-inline.hh"
#include "eval-settings.hh"
#include "signals.hh"
#include "terminal.hh"
#include "util.hh"
#include "get-drvs.hh"
#include "globals.hh"
Expand Down Expand Up @@ -54,7 +56,7 @@ using namespace nix;
static Path gcRootsDir;
static size_t maxMemorySize;

struct MyArgs : MixEvalArgs, MixCommonArgs
struct MyArgs : MixEvalArgs, MixCommonArgs, RootArgs
{
Path releaseExpr;
bool flake = false;
Expand Down Expand Up @@ -95,7 +97,7 @@ static std::string queryMetaStrings(EvalState & state, DrvInfo & drv, const std:
rec = [&](Value & v) {
state.forceValue(v, noPos);
if (v.type() == nString)
res.push_back(v.string.s);
res.emplace_back(v.string_view());
else if (v.isList())
for (unsigned int n = 0; n < v.listSize(); ++n)
rec(*v.listElems()[n]);
Expand Down Expand Up @@ -222,7 +224,7 @@ static void worker(
auto v = a->value->listElems()[n];
state.forceValue(*v, noPos);
if (v->type() == nString)
job["namedConstituents"].push_back(v->str());
job["namedConstituents"].push_back(v->string_view());
}
}

Expand Down
1 change: 1 addition & 0 deletions src/hydra-evaluator/hydra-evaluator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "hydra-config.hh"
#include "pool.hh"
#include "shared.hh"
#include "signals.hh"

#include <algorithm>
#include <thread>
Expand Down
43 changes: 29 additions & 14 deletions src/hydra-queue-runner/build-remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
#include "path.hh"
#include "serve-protocol.hh"
#include "state.hh"
#include "current-process.hh"
#include "processes.hh"
#include "util.hh"
#include "worker-protocol.hh"
#include "worker-protocol-impl.hh"
#include "serve-protocol.hh"
#include "serve-protocol-impl.hh"
#include "finally.hh"
#include "url.hh"

Expand Down Expand Up @@ -106,26 +108,32 @@ static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Chil


static void copyClosureTo(std::timed_mutex & sendMutex, Store & destStore,
FdSource & from, FdSink & to, const StorePathSet & paths,
FdSource & from, FdSink & to, ServeProto::Version remoteVersion, const StorePathSet & paths,
bool useSubstitutes = false)
{
StorePathSet closure;
destStore.computeFSClosure(paths, closure);

WorkerProto::WriteConn wconn { .to = to };
WorkerProto::ReadConn rconn { .from = from };
ServeProto::WriteConn wconn {
.to = to,
.version = remoteVersion,
};
ServeProto::ReadConn rconn {
.from = from,
.version = remoteVersion,
};
/* 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 << ServeProto::Command::QueryValidPaths << 1 << useSubstitutes;
WorkerProto::write(destStore, wconn, closure);
ServeProto::write(destStore, wconn, closure);
to.flush();

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

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

Expand Down Expand Up @@ -227,17 +235,15 @@ 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;
bytesSent += to.written;
});

/* Handshake. */
unsigned int remoteVersion;
ServeProto::Version remoteVersion;

try {
to << SERVE_MAGIC_1 << 0x206;
Expand All @@ -258,6 +264,15 @@ void State::buildRemote(ref<Store> destStore,
throw Error("cannot connect to ‘%1%’: %2%", machine->sshName, s);
}

ServeProto::ReadConn rconn {
.from = from,
.version = remoteVersion,
};
ServeProto::WriteConn wconn {
.to = to,
.version = remoteVersion,
};

Comment on lines +267 to +275
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved down because we don't know the versions until after the handshake

{
auto info(machine->state->connectInfo.lock());
info->consecutiveFailures = 0;
Expand Down Expand Up @@ -313,7 +328,7 @@ void State::buildRemote(ref<Store> destStore,
destStore->computeFSClosure(inputs, closure);
copyPaths(*destStore, *localStore, closure, NoRepair, NoCheckSigs, NoSubstitute);
} else {
copyClosureTo(machine->state->sendLock, *destStore, from, to, inputs, true);
copyClosureTo(machine->state->sendLock, *destStore, from, to, remoteVersion, inputs, true);
}

auto now2 = std::chrono::steady_clock::now();
Expand Down Expand Up @@ -373,7 +388,7 @@ void State::buildRemote(ref<Store> destStore,
}
}
if (GET_PROTOCOL_MINOR(remoteVersion) >= 6) {
WorkerProto::Serialise<DrvOutputs>::read(*localStore, rconn);
ServeProto::Serialise<DrvOutputs>::read(*localStore, rconn);
}
switch ((BuildResult::Status) res) {
case BuildResult::Built:
Expand Down Expand Up @@ -450,13 +465,13 @@ void State::buildRemote(ref<Store> destStore,
std::map<StorePath, ValidPathInfo> infos;
size_t totalNarSize = 0;
to << ServeProto::Command::QueryPathInfos;
WorkerProto::write(*localStore, wconn, outputs);
ServeProto::write(*localStore, wconn, outputs);
to.flush();
while (true) {
auto storePathS = readString(from);
if (storePathS == "") break;
auto deriver = readString(from); // deriver
auto references = WorkerProto::Serialise<StorePathSet>::read(*localStore, rconn);
auto references = ServeProto::Serialise<StorePathSet>::read(*localStore, rconn);
readLongLong(from); // download size
auto narSize = readLongLong(from);
auto narHash = Hash::parseAny(readString(from), htSHA256);
Expand Down
12 changes: 6 additions & 6 deletions src/hydra-queue-runner/build-result.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "hydra-build-result.hh"
#include "store-api.hh"
#include "util.hh"
#include "fs-accessor.hh"
#include "source-accessor.hh"

#include <regex>

Expand Down Expand Up @@ -63,7 +63,7 @@ BuildOutput getBuildOutput(

auto productsFile = narMembers.find(outputS + "/nix-support/hydra-build-products");
if (productsFile == narMembers.end() ||
productsFile->second.type != FSAccessor::Type::tRegular)
productsFile->second.type != SourceAccessor::Type::tRegular)
continue;
assert(productsFile->second.contents);

Expand Down Expand Up @@ -94,7 +94,7 @@ BuildOutput getBuildOutput(

product.name = product.path == store->printStorePath(output) ? "" : baseNameOf(product.path);

if (file->second.type == FSAccessor::Type::tRegular) {
if (file->second.type == SourceAccessor::Type::tRegular) {
product.isRegular = true;
product.fileSize = file->second.fileSize.value();
product.sha256hash = file->second.sha256.value();
Expand All @@ -117,7 +117,7 @@ BuildOutput getBuildOutput(

auto file = narMembers.find(product.path);
assert(file != narMembers.end());
if (file->second.type == FSAccessor::Type::tDirectory)
if (file->second.type == SourceAccessor::Type::tDirectory)
res.products.push_back(product);
}
}
Expand All @@ -126,7 +126,7 @@ BuildOutput getBuildOutput(
for (auto & output : outputs) {
auto file = narMembers.find(store->printStorePath(output) + "/nix-support/hydra-release-name");
if (file == narMembers.end() ||
file->second.type != FSAccessor::Type::tRegular)
file->second.type != SourceAccessor::Type::tRegular)
continue;
res.releaseName = trim(file->second.contents.value());
// FIXME: validate release name
Expand All @@ -136,7 +136,7 @@ BuildOutput getBuildOutput(
for (auto & output : outputs) {
auto file = narMembers.find(store->printStorePath(output) + "/nix-support/hydra-metrics");
if (file == narMembers.end() ||
file->second.type != FSAccessor::Type::tRegular)
file->second.type != SourceAccessor::Type::tRegular)
continue;
for (auto & line : tokenizeString<Strings>(file->second.contents.value(), "\n")) {
auto fields = tokenizeString<std::vector<std::string>>(line);
Expand Down
3 changes: 2 additions & 1 deletion src/hydra-queue-runner/hydra-queue-runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <nlohmann/json.hpp>

#include "signals.hh"
#include "state.hh"
#include "hydra-build-result.hh"
#include "store-api.hh"
Expand Down Expand Up @@ -467,7 +468,7 @@ void State::markSucceededBuild(pqxx::work & txn, Build::ptr build,
product.type,
product.subtype,
product.fileSize ? std::make_optional(*product.fileSize) : std::nullopt,
product.sha256hash ? std::make_optional(product.sha256hash->to_string(Base16, false)) : std::nullopt,
product.sha256hash ? std::make_optional(product.sha256hash->to_string(HashFormat::Base16, false)) : std::nullopt,
product.path,
product.name,
product.defaultPath);
Expand Down
12 changes: 9 additions & 3 deletions src/hydra-queue-runner/nar-extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ struct Extractor : ParseSink

void createDirectory(const Path & path) override
{
members.insert_or_assign(prefix + path, NarMemberData { .type = FSAccessor::Type::tDirectory });
members.insert_or_assign(prefix + path, NarMemberData { .type = SourceAccessor::Type::tDirectory });
}

void createRegularFile(const Path & path) override
{
curMember = &members.insert_or_assign(prefix + path, NarMemberData {
.type = FSAccessor::Type::tRegular,
.type = SourceAccessor::Type::tRegular,
.fileSize = 0,
.contents = filesToKeep.count(path) ? std::optional("") : std::nullopt,
}).first->second;
Expand Down Expand Up @@ -66,8 +66,14 @@ struct Extractor : ParseSink

void createSymlink(const Path & path, const std::string & target) override
{
members.insert_or_assign(prefix + path, NarMemberData { .type = FSAccessor::Type::tSymlink });
members.insert_or_assign(prefix + path, NarMemberData { .type = SourceAccessor::Type::tSymlink });
}

void isExecutable() override
{ }

void closeRegularFile() override
{ }
Comment on lines +72 to +76
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These when from being such empty functions in the interface to = 0 virtual pure ones, so putting the old do-nothing implementations here.

};


Expand Down
4 changes: 2 additions & 2 deletions src/hydra-queue-runner/nar-extractor.hh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once

#include "fs-accessor.hh"
#include "source-accessor.hh"
#include "types.hh"
#include "serialise.hh"
#include "hash.hh"

struct NarMemberData
{
nix::FSAccessor::Type type;
nix::SourceAccessor::Type type;
std::optional<uint64_t> fileSize;
std::optional<std::string> contents;
std::optional<nix::Hash> sha256;
Expand Down
1 change: 1 addition & 0 deletions src/libhydra/db.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <pqxx/pqxx>

#include "environment-variables.hh"
#include "util.hh"


Expand Down
1 change: 1 addition & 0 deletions src/libhydra/hydra-config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <map>

#include "file-system.hh"
#include "util.hh"

struct HydraConfig
Expand Down
Loading