diff --git a/flake.lock b/flake.lock index fa71ceb5..d5c5e613 100644 --- a/flake.lock +++ b/flake.lock @@ -3,16 +3,15 @@ "lowdown-src": { "flake": false, "locked": { - "lastModified": 1617481909, - "narHash": "sha256-SqnfOFuLuVRRNeVJr1yeEPJue/qWoCp5N6o5Kr///p4=", + "lastModified": 1633514407, + "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", "owner": "kristapsdz", "repo": "lowdown", - "rev": "148f9b2f586c41b7e36e73009db43ea68c7a1a4d", + "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", "type": "github" }, "original": { "owner": "kristapsdz", - "ref": "VERSION_0_8_4", "repo": "lowdown", "type": "github" } @@ -20,28 +19,31 @@ "nix": { "inputs": { "lowdown-src": "lowdown-src", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "nixpkgs-regression": "nixpkgs-regression" }, "locked": { - "lastModified": 1628586117, - "narHash": "sha256-8hS4xy7fq3z9XZIMYm4sQi9SzhcYqEJfdbwgDePoWuc=", + "lastModified": 1646680282, + "narHash": "sha256-m8tqCS6uHveDon5GSro5yZor9H+sHeh+v/veF1IGw24=", "owner": "NixOS", "repo": "nix", - "rev": "a6ba313a0aac3b6e2fef434cb42d190a0849238e", + "rev": "ffe155abd36366a870482625543f9bf924a58281", "type": "github" }, "original": { - "id": "nix", - "type": "indirect" + "owner": "NixOS", + "ref": "2.7.0", + "repo": "nix", + "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1624862269, - "narHash": "sha256-JFcsh2+7QtfKdJFoPibLFPLgIW6Ycnv8Bts9a7RYme0=", + "lastModified": 1632864508, + "narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f77036342e2b690c61c97202bf48f2ce13acc022", + "rev": "82891b5e2c2359d7e58d08849e4c89511ab94234", "type": "github" }, "original": { @@ -50,6 +52,21 @@ "type": "indirect" } }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "indirect" + } + }, "root": { "inputs": { "nix": "nix", diff --git a/flake.nix b/flake.nix index 56cb2960..7c21b68d 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,7 @@ description = "A Nix-based continuous build system"; inputs.nixpkgs.follows = "nix/nixpkgs"; + inputs.nix.url = github:NixOS/nix/2.7.0; outputs = { self, nixpkgs, nix }: let diff --git a/src/hydra-eval-jobs/hydra-eval-jobs.cc b/src/hydra-eval-jobs/hydra-eval-jobs.cc index 44a273a9..ba92113e 100644 --- a/src/hydra-eval-jobs/hydra-eval-jobs.cc +++ b/src/hydra-eval-jobs/hydra-eval-jobs.cc @@ -63,13 +63,13 @@ struct MyArgs : MixEvalArgs, MixCommonArgs static MyArgs myArgs; -static std::string queryMetaStrings(EvalState & state, DrvInfo & drv, const string & name, const string & subAttribute) +static std::string queryMetaStrings(EvalState & state, DrvInfo & drv, const std::string & name, const std::string & subAttribute) { Strings res; std::function rec; rec = [&](Value & v) { - state.forceValue(v); + state.forceValue(v, noPos); if (v.type() == nString) res.push_back(v.string.s); else if (v.isList()) @@ -78,7 +78,7 @@ static std::string queryMetaStrings(EvalState & state, DrvInfo & drv, const stri else if (v.type() == nAttrs) { auto a = v.attrs->find(state.symbols.create(subAttribute)); if (a != v.attrs->end()) - res.push_back(state.forceString(*a->value)); + res.push_back(std::string(state.forceString(*a->value))); } }; @@ -113,7 +113,7 @@ static void worker( callFlake(state, lockedFlake, *vFlake); auto vOutputs = vFlake->attrs->get(state.symbols.create("outputs"))->value; - state.forceValue(*vOutputs); + state.forceValue(*vOutputs, noPos); auto aHydraJobs = vOutputs->attrs->get(state.symbols.create("hydraJobs")); if (!aHydraJobs) @@ -157,7 +157,7 @@ static void worker( if (drv->querySystem() == "unknown") throw EvalError("derivation must have a 'system' attribute"); - auto drvPath = drv->queryDrvPath(); + auto drvPath = state.store->printStorePath(drv->requireDrvPath()); nlohmann::json job; @@ -186,13 +186,13 @@ static void worker( for (auto & i : context) if (i.at(0) == '!') { size_t index = i.find("!", 1); - job["constituents"].push_back(string(i, index + 1)); + job["constituents"].push_back(std::string(i, index + 1)); } state.forceList(*a->value, *a->pos); for (unsigned int n = 0; n < a->value->listSize(); ++n) { auto v = a->value->listElems()[n]; - state.forceValue(*v); + state.forceValue(*v, noPos); if (v->type() == nString) job["namedConstituents"].push_back(state.forceStringNoCtx(*v)); } @@ -210,7 +210,7 @@ static void worker( nlohmann::json out; for (auto & j : outputs) - out[j.first] = j.second; + out[j.first] = state.store->printStorePath(j.second); job["outputs"] = std::move(out); reply["job"] = std::move(job); diff --git a/src/hydra-queue-runner/Makefile.am b/src/hydra-queue-runner/Makefile.am index ea852334..57808608 100644 --- a/src/hydra-queue-runner/Makefile.am +++ b/src/hydra-queue-runner/Makefile.am @@ -2,7 +2,7 @@ bin_PROGRAMS = hydra-queue-runner hydra_queue_runner_SOURCES = hydra-queue-runner.cc queue-monitor.cc dispatcher.cc \ builder.cc build-result.cc build-remote.cc \ - build-result.hh counter.hh state.hh db.hh \ + hydra-build-result.hh counter.hh state.hh db.hh \ nar-extractor.cc nar-extractor.hh hydra_queue_runner_LDADD = $(NIX_LIBS) -lpqxx hydra_queue_runner_CXXFLAGS = $(NIX_CFLAGS) -Wall -I ../libhydra -Wno-deprecated-declarations diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc index 464a35c8..bdbd44b9 100644 --- a/src/hydra-queue-runner/build-remote.cc +++ b/src/hydra-queue-runner/build-remote.cc @@ -5,6 +5,7 @@ #include #include +#include "build-result.hh" #include "serve-protocol.hh" #include "state.hh" #include "util.hh" @@ -49,7 +50,7 @@ static Strings extraStoreArgs(std::string & machine) static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Child & child) { - string pgmName; + std::string pgmName; Pipe to, from; to.create(); from.create(); @@ -81,7 +82,7 @@ static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Chil if (machine->sshPublicHostKey != "") { Path fileName = tmpDir + "/host-key"; auto p = machine->sshName.find("@"); - string host = p != string::npos ? string(machine->sshName, p + 1) : machine->sshName; + std::string host = p != std::string::npos ? std::string(machine->sshName, p + 1) : machine->sshName; writeFile(fileName, host + " " + machine->sshPublicHostKey + "\n"); append(argv, {"-oUserKnownHostsFile=" + fileName}); } @@ -185,8 +186,8 @@ void State::buildRemote(ref destStore, { assert(BuildResult::TimedOut == 8); - string base(step->drvPath.to_string()); - result.logFile = logDir + "/" + string(base, 0, 2) + "/" + string(base, 2); + std::string base(step->drvPath.to_string()); + result.logFile = logDir + "/" + std::string(base, 0, 2) + "/" + std::string(base, 2); AutoDelete autoDelete(result.logFile, false); createDirs(dirOf(result.logFile)); @@ -249,7 +250,7 @@ void State::buildRemote(ref destStore, } catch (EndOfFile & e) { child.pid.wait(); - string s = chomp(readFile(result.logFile)); + std::string s = chomp(readFile(result.logFile)); throw Error("cannot connect to ‘%1%’: %2%", machine->sshName, s); } @@ -287,9 +288,9 @@ void State::buildRemote(ref destStore, this will copy the inputs to the binary cache from the local store. */ if (localStore != std::shared_ptr(destStore)) { - StorePathSet closure; - localStore->computeFSClosure(step->drv->inputSrcs, closure); - copyPaths(*localStore, *destStore, closure, NoRepair, NoCheckSigs, NoSubstitute); + copyClosure(*localStore, *destStore, + step->drv->inputSrcs, + NoRepair, NoCheckSigs, NoSubstitute); } { diff --git a/src/hydra-queue-runner/build-result.cc b/src/hydra-queue-runner/build-result.cc index f69bf0df..ea8b4a6a 100644 --- a/src/hydra-queue-runner/build-result.cc +++ b/src/hydra-queue-runner/build-result.cc @@ -1,4 +1,4 @@ -#include "build-result.hh" +#include "hydra-build-result.hh" #include "store-api.hh" #include "util.hh" #include "fs-accessor.hh" @@ -78,7 +78,7 @@ BuildOutput getBuildOutput( product.type = match[1]; product.subtype = match[2]; std::string s(match[3]); - product.path = s[0] == '"' ? string(s, 1, s.size() - 2) : s; + product.path = s[0] == '"' ? std::string(s, 1, s.size() - 2) : s; product.defaultPath = match[5]; /* Ensure that the path exists and points into the Nix diff --git a/src/hydra-queue-runner/builder.cc b/src/hydra-queue-runner/builder.cc index 89aa7d15..37022522 100644 --- a/src/hydra-queue-runner/builder.cc +++ b/src/hydra-queue-runner/builder.cc @@ -1,7 +1,7 @@ #include #include "state.hh" -#include "build-result.hh" +#include "hydra-build-result.hh" #include "finally.hh" #include "binary-cache-store.hh" diff --git a/src/hydra-queue-runner/build-result.hh b/src/hydra-queue-runner/hydra-build-result.hh similarity index 100% rename from src/hydra-queue-runner/build-result.hh rename to src/hydra-queue-runner/hydra-build-result.hh diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index 3297730c..615e470b 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -7,7 +7,7 @@ #include #include "state.hh" -#include "build-result.hh" +#include "hydra-build-result.hh" #include "store-api.hh" #include "remote-store.hh" @@ -87,7 +87,7 @@ void State::parseMachines(const std::string & contents) } for (auto line : tokenizeString(contents, "\n")) { - line = trim(string(line, 0, line.find('#'))); + line = trim(std::string(line, 0, line.find('#'))); auto tokens = tokenizeString>(line); if (tokens.size() < 3) continue; tokens.resize(8); @@ -95,7 +95,7 @@ void State::parseMachines(const std::string & contents) auto machine = std::make_shared(); machine->sshName = tokens[0]; machine->systemTypes = tokenizeString(tokens[1], ","); - machine->sshKey = tokens[2] == "-" ? string("") : tokens[2]; + machine->sshKey = tokens[2] == "-" ? std::string("") : tokens[2]; if (tokens[3] != "") machine->maxJobs = string2IntmaxJobs)>(tokens[3]).value(); else @@ -149,7 +149,7 @@ void State::parseMachines(const std::string & contents) void State::monitorMachinesFile() { - string defaultMachinesFile = "/etc/nix/machines"; + std::string defaultMachinesFile = "/etc/nix/machines"; auto machinesFiles = tokenizeString>( getEnv("NIX_REMOTE_SYSTEMS").value_or(pathExists(defaultMachinesFile) ? defaultMachinesFile : ""), ":"); @@ -191,7 +191,7 @@ void State::monitorMachinesFile() debug("reloading machines files"); - string contents; + std::string contents; for (auto & machinesFile : machinesFiles) { try { contents += readFile(machinesFile); @@ -308,7 +308,7 @@ void State::finishBuildStep(pqxx::work & txn, const RemoteResult & result, int State::createSubstitutionStep(pqxx::work & txn, time_t startTime, time_t stopTime, - Build::ptr build, const StorePath & drvPath, const string & outputName, const StorePath & storePath) + Build::ptr build, const StorePath & drvPath, const std::string & outputName, const StorePath & storePath) { restart: auto stepNr = allocBuildStep(txn, build->id); @@ -683,14 +683,14 @@ void State::showStatus() auto conn(dbPool.get()); receiver statusDumped(*conn, "status_dumped"); - string status; + std::string status; bool barf = false; /* Get the last JSON status dump from the database. */ { pqxx::work txn(*conn); auto res = txn.exec("select status from SystemStatus where what = 'queue-runner'"); - if (res.size()) status = res[0][0].as(); + if (res.size()) status = res[0][0].as(); } if (status != "") { @@ -710,7 +710,7 @@ void State::showStatus() { pqxx::work txn(*conn); auto res = txn.exec("select status from SystemStatus where what = 'queue-runner'"); - if (res.size()) status = res[0][0].as(); + if (res.size()) status = res[0][0].as(); } } diff --git a/src/hydra-queue-runner/nar-extractor.cc b/src/hydra-queue-runner/nar-extractor.cc index 260296c9..9f0eb431 100644 --- a/src/hydra-queue-runner/nar-extractor.cc +++ b/src/hydra-queue-runner/nar-extractor.cc @@ -64,7 +64,7 @@ struct Extractor : ParseSink } } - void createSymlink(const Path & path, const string & target) override + void createSymlink(const Path & path, const std::string & target) override { members.insert_or_assign(prefix + path, NarMemberData { .type = FSAccessor::Type::tSymlink }); } diff --git a/src/hydra-queue-runner/queue-monitor.cc b/src/hydra-queue-runner/queue-monitor.cc index 49caf8e3..6a5a82db 100644 --- a/src/hydra-queue-runner/queue-monitor.cc +++ b/src/hydra-queue-runner/queue-monitor.cc @@ -1,5 +1,5 @@ #include "state.hh" -#include "build-result.hh" +#include "hydra-build-result.hh" #include "globals.hh" #include @@ -111,12 +111,12 @@ bool State::getQueuedBuilds(Connection & conn, if (builds_->count(id)) continue; auto build = std::make_shared( - localStore->parseStorePath(row["drvPath"].as())); + localStore->parseStorePath(row["drvPath"].as())); build->id = id; build->jobsetId = row["jobset_id"].as(); - build->projectName = row["project"].as(); - build->jobsetName = row["jobset"].as(); - build->jobName = row["job"].as(); + build->projectName = row["project"].as(); + build->jobsetName = row["jobset"].as(); + build->jobName = row["job"].as(); build->maxSilentTime = row["maxsilent"].as(); build->buildTimeout = row["timeout"].as(); build->timestamp = row["timestamp"].as(); @@ -513,9 +513,9 @@ Step::ptr State::createStep(ref destStore, // FIXME: should copy directly from substituter to destStore. } - StorePathSet closure; - localStore->computeFSClosure({*path}, closure); - copyPaths(*localStore, *destStore, closure, NoRepair, CheckSigs, NoSubstitute); + copyClosure(*localStore, *destStore, + StorePathSet { *path }, + NoRepair, CheckSigs, NoSubstitute); time_t stopTime = time(0); @@ -620,7 +620,7 @@ void State::processJobsetSharesChange(Connection & conn) auto res = txn.exec("select project, name, schedulingShares from Jobsets"); for (auto const & row : res) { auto jobsets_(jobsets.lock()); - auto i = jobsets_->find(std::make_pair(row["project"].as(), row["name"].as())); + auto i = jobsets_->find(std::make_pair(row["project"].as(), row["name"].as())); if (i == jobsets_->end()) continue; i->second->setShares(row["schedulingShares"].as()); } diff --git a/src/hydra-queue-runner/state.hh b/src/hydra-queue-runner/state.hh index 8f303d28..7c375cb9 100644 --- a/src/hydra-queue-runner/state.hh +++ b/src/hydra-queue-runner/state.hh @@ -12,6 +12,7 @@ #include "parsed-derivations.hh" #include "pathlocks.hh" #include "pool.hh" +#include "build-result.hh" #include "store-api.hh" #include "sync.hh" #include "nar-extractor.hh" diff --git a/src/libhydra/db.hh b/src/libhydra/db.hh index 7d5bdc58..00e8f406 100644 --- a/src/libhydra/db.hh +++ b/src/libhydra/db.hh @@ -18,7 +18,7 @@ struct Connection : pqxx::connection std::string upper_prefix = "DBI:Pg:"; if (hasPrefix(s, lower_prefix) || hasPrefix(s, upper_prefix)) { - return concatStringsSep(" ", tokenizeString(string(s, lower_prefix.size()), ";")); + return concatStringsSep(" ", tokenizeString(std::string(s, lower_prefix.size()), ";")); } throw Error("$HYDRA_DBI does not denote a PostgreSQL database"); diff --git a/src/libhydra/hydra-config.hh b/src/libhydra/hydra-config.hh index bc989f74..1688c278 100644 --- a/src/libhydra/hydra-config.hh +++ b/src/libhydra/hydra-config.hh @@ -17,7 +17,7 @@ struct HydraConfig if (hydraConfigFile && pathExists(*hydraConfigFile)) { for (auto line : tokenizeString(readFile(*hydraConfigFile), "\n")) { - line = trim(string(line, 0, line.find('#'))); + line = trim(std::string(line, 0, line.find('#'))); auto eq = line.find('='); if (eq == std::string::npos) continue;