Compare commits

..

5 Commits

Author SHA1 Message Date
John Ericson
f3dc4e9228 WIP ssh-ng:// 2025-02-14 18:51:49 -05:00
John Ericson
45d075e5db WIP: Avoid custom logic copying outputs from the remote builder
We need a replacement for the nar member logic, however. And maybe also
a test that fails until this is fixed (this one should not be passing).
2025-02-14 18:50:38 -05:00
John Ericson
9e162dcf52 Avoid custom logic to copy inputs to the remote builder 2025-02-14 18:50:38 -05:00
John Ericson
4c173daec7 Use LegacySSHStore
In https://github.com/NixOS/nix/pull/10748 it is extended with
everything we need.
2025-02-14 18:48:46 -05:00
John Ericson
8675aee25b WIP TEMP nix update, don't mere this!
Not until https://github.com/NixOS/nix/pull/10748 lands

Flake lock file updates:

• Updated input 'nix':
    'github:NixOS/nix/970942f45836172fda410a638853382952189eb9?narHash=sha256-jGFuyYKJjJZsBRoi7ZcaVKt1OYxusz/ld1HA7VD2w/0%3D' (2025-02-12)
  → 'github:NixOS/nix/5eade4825221d3284fc6555cb20de2c7aa171d72?narHash=sha256-n5kdS1C24tlJxDV6Wm1iBlyvGk%2Bp0gMXRcWVCAipYLs%3D' (2025-02-14)

• Updated input 'nix-eval-jobs':
    'github:Ericson2314/nix-eval-jobs/5e27c2724a4b07862e7ff1a198aa2ed68dea3e2c?narHash=sha256-7xgSdKnQW11eWd59MnpUNS%2BgwgtOJH2ShzLwByev3rg%3D' (2025-02-14)
  → 'github:Ericson2314/nix-eval-jobs/de345eb4518d952c2d86261b270f2c31edecd3de?narHash=sha256-dNMJY6%2BG3PwE8lIAhwetPJdA2DxCEKRXPY/EtHmdDh4%3D' (2025-02-14)
2025-02-14 18:15:22 -05:00
6 changed files with 40 additions and 47 deletions

20
flake.lock generated
View File

@@ -5,6 +5,7 @@
"flake-compat": [], "flake-compat": [],
"flake-parts": [], "flake-parts": [],
"git-hooks-nix": [], "git-hooks-nix": [],
"nixfmt": [],
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
], ],
@@ -12,16 +13,16 @@
"nixpkgs-regression": [] "nixpkgs-regression": []
}, },
"locked": { "locked": {
"lastModified": 1739899400, "lastModified": 1739571938,
"narHash": "sha256-q/RgA4bB7zWai4oPySq9mch7qH14IEeom2P64SXdqHs=", "narHash": "sha256-NlaLAed/xei6RWpU2HIIbDjILRC4l1NIfGeyrn7ALQs=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nix", "repo": "nix",
"rev": "e310c19a1aeb1ce1ed4d41d5ab2d02db596e0918", "rev": "ffc649d2eabdd3e678b5bcc211dd59fd06debf3e",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "2.26-maintenance", "ref": "ssh-ng-extensions-for-hydra",
"repo": "nix", "repo": "nix",
"type": "github" "type": "github"
} }
@@ -29,15 +30,16 @@
"nix-eval-jobs": { "nix-eval-jobs": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1739500569, "lastModified": 1739499741,
"narHash": "sha256-3wIReAqdTALv39gkWXLMZQvHyBOc3yPkWT2ZsItxedY=", "narHash": "sha256-dNMJY6+G3PwE8lIAhwetPJdA2DxCEKRXPY/EtHmdDh4=",
"owner": "nix-community", "owner": "Ericson2314",
"repo": "nix-eval-jobs", "repo": "nix-eval-jobs",
"rev": "4b392b284877d203ae262e16af269f702df036bc", "rev": "de345eb4518d952c2d86261b270f2c31edecd3de",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nix-community", "owner": "Ericson2314",
"ref": "nix-2.27",
"repo": "nix-eval-jobs", "repo": "nix-eval-jobs",
"type": "github" "type": "github"
} }

View File

@@ -4,7 +4,7 @@
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11-small"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11-small";
inputs.nix = { inputs.nix = {
url = "github:NixOS/nix/2.26-maintenance"; url = "github:NixOS/nix/ssh-ng-extensions-for-hydra";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
# hide nix dev tooling from our lock file # hide nix dev tooling from our lock file
@@ -13,10 +13,11 @@
inputs.nixpkgs-regression.follows = ""; inputs.nixpkgs-regression.follows = "";
inputs.nixpkgs-23-11.follows = ""; inputs.nixpkgs-23-11.follows = "";
inputs.flake-compat.follows = ""; inputs.flake-compat.follows = "";
inputs.nixfmt.follows = "";
}; };
inputs.nix-eval-jobs = { inputs.nix-eval-jobs = {
url = "github:nix-community/nix-eval-jobs"; url = "github:Ericson2314/nix-eval-jobs/nix-2.27";
# We want to control the deps precisely # We want to control the deps precisely
flake = false; flake = false;
}; };

View File

@@ -7,7 +7,7 @@
#include "build-result.hh" #include "build-result.hh"
#include "path.hh" #include "path.hh"
#include "legacy-ssh-store.hh" #include "ssh-store.hh"
#include "serve-protocol.hh" #include "serve-protocol.hh"
#include "state.hh" #include "state.hh"
#include "current-process.hh" #include "current-process.hh"
@@ -119,11 +119,10 @@ static BuildResult performBuild(
Store & localStore, Store & localStore,
StorePath drvPath, StorePath drvPath,
const BasicDerivation & drv, const BasicDerivation & drv,
const ServeProto::BuildOptions & options,
counter & nrStepsBuilding counter & nrStepsBuilding
) )
{ {
auto kont = conn.store->buildDerivationAsync(drvPath, drv, options); auto kont = conn.store->buildDerivationAsync(drvPath, drv, bmNormal);
BuildResult result; BuildResult result;
@@ -238,7 +237,6 @@ void RemoteResult::updateWithBuildResult(const nix::BuildResult & buildResult)
void State::buildRemote(ref<Store> destStore, void State::buildRemote(ref<Store> destStore,
::Machine::ptr machine, Step::ptr step, ::Machine::ptr machine, Step::ptr step,
const ServeProto::BuildOptions & buildOptions,
RemoteResult & result, std::shared_ptr<ActiveStep> activeStep, RemoteResult & result, std::shared_ptr<ActiveStep> activeStep,
std::function<void(StepState)> updateStep, std::function<void(StepState)> updateStep,
NarMemberDatas & narMembers) NarMemberDatas & narMembers)
@@ -258,25 +256,26 @@ void State::buildRemote(ref<Store> destStore,
.machine = machine, .machine = machine,
.store = [&]{ .store = [&]{
auto * pSpecified = std::get_if<StoreReference::Specified>(&machine->storeUri.variant); auto * pSpecified = std::get_if<StoreReference::Specified>(&machine->storeUri.variant);
if (!pSpecified || pSpecified->scheme != "ssh") { if (!pSpecified || pSpecified->scheme != "ssh-ng") {
throw Error("Currently, only (legacy-)ssh stores are supported!"); throw Error("Currently, only ssh-ng:// stores are supported!");
} }
auto remoteStore = machine->openStore().dynamic_pointer_cast<LegacySSHStore>(); auto remoteStore = machine->openStore().dynamic_pointer_cast<RemoteStore>();
auto remoteStoreConfig = std::dynamic_pointer_cast<SSHStoreConfig>(remoteStore);
assert(remoteStore); assert(remoteStore);
remoteStore->connPipeSize = 1024 * 1024;
if (machine->isLocalhost()) { if (machine->isLocalhost()) {
auto rp_new = remoteStore->remoteProgram.get(); auto rp_new = remoteStoreConfig->remoteProgram.get();
rp_new.push_back("--builders"); rp_new.push_back("--builders");
rp_new.push_back(""); rp_new.push_back("");
const_cast<nix::Setting<Strings> &>(remoteStore->remoteProgram).assign(rp_new); const_cast<nix::Setting<Strings> &>(remoteStoreConfig->remoteProgram).assign(rp_new);
} }
remoteStore->extraSshArgs = { remoteStoreConfig->extraSshArgs = {
"-a", "-oBatchMode=yes", "-oConnectTimeout=60", "-oTCPKeepAlive=yes" "-a", "-oBatchMode=yes", "-oConnectTimeout=60", "-oTCPKeepAlive=yes"
}; };
const_cast<nix::Setting<int> &>(remoteStore->logFD).assign(logFD.get());
// TODO logging
//const_cast<nix::Setting<int> &>(remoteStore->logFD).assign(logFD.get());
return nix::ref{remoteStore}; return nix::ref{remoteStore};
}(), }(),
@@ -285,12 +284,10 @@ void State::buildRemote(ref<Store> destStore,
{ {
auto activeStepState(activeStep->state_.lock()); auto activeStepState(activeStep->state_.lock());
if (activeStepState->cancelled) throw Error("step cancelled"); if (activeStepState->cancelled) throw Error("step cancelled");
activeStepState->pid = conn.store->getConnectionPid();
} }
Finally clearPid([&]() { Finally clearPid([&]() {
auto activeStepState(activeStep->state_.lock()); auto activeStepState(activeStep->state_.lock());
activeStepState->pid = -1;
/* FIXME: there is a slight race here with step /* FIXME: there is a slight race here with step
cancellation in State::processQueueChange(), which cancellation in State::processQueueChange(), which
@@ -301,9 +298,10 @@ void State::buildRemote(ref<Store> destStore,
}); });
Finally updateStats([&]() { Finally updateStats([&]() {
auto stats = conn.store->getConnectionStats(); // TODO
bytesReceived += stats.bytesReceived; //auto stats = conn.store->getConnectionStats();
bytesSent += stats.bytesSent; //bytesReceived += stats.bytesReceived;
//bytesSent += stats.bytesSent;
}); });
{ {
@@ -343,7 +341,6 @@ void State::buildRemote(ref<Store> destStore,
*localStore, *localStore,
step->drvPath, step->drvPath,
resolvedDrv, resolvedDrv,
buildOptions,
nrStepsBuilding nrStepsBuilding
); );

View File

@@ -98,13 +98,6 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
it). */ it). */
BuildID buildId; BuildID buildId;
std::optional<StorePath> buildDrvPath; std::optional<StorePath> buildDrvPath;
// Other fields set below
nix::ServeProto::BuildOptions buildOptions {
.maxLogSize = maxLogSize,
.nrRepeats = step->isDeterministic ? 1u : 0u,
.enforceDeterminism = step->isDeterministic,
.keepFailed = false,
};
auto conn(dbPool.get()); auto conn(dbPool.get());
@@ -139,18 +132,19 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
{ {
auto i = jobsetRepeats.find(std::make_pair(build2->projectName, build2->jobsetName)); auto i = jobsetRepeats.find(std::make_pair(build2->projectName, build2->jobsetName));
if (i != jobsetRepeats.end()) if (i != jobsetRepeats.end())
buildOptions.nrRepeats = std::max(buildOptions.nrRepeats, i->second); warn("jobset repeats is deprecated; nix stopped supporting this correctly a long time ago.");
} }
} }
if (!build) build = *dependents.begin(); if (!build) build = *dependents.begin();
buildId = build->id; buildId = build->id;
buildDrvPath = build->drvPath; buildDrvPath = build->drvPath;
buildOptions.maxSilentTime = build->maxSilentTime; settings.maxLogSize = maxLogSize;
buildOptions.buildTimeout = build->buildTimeout; settings.maxSilentTime = build->maxSilentTime;
settings.buildTimeout = build->buildTimeout;
printInfo("performing step %s %d times on %s (needed by build %d and %d others)", printInfo("performing step %s %d times on %s (needed by build %d and %d others)",
localStore->printStorePath(step->drvPath), buildOptions.nrRepeats + 1, machine->storeUri.render(), buildId, (dependents.size() - 1)); localStore->printStorePath(step->drvPath), 1, machine->storeUri.render(), buildId, (dependents.size() - 1));
} }
if (!buildOneDone) if (!buildOneDone)
@@ -211,7 +205,7 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
try { try {
/* FIXME: referring builds may have conflicting timeouts. */ /* FIXME: referring builds may have conflicting timeouts. */
buildRemote(destStore, machine, step, buildOptions, result, activeStep, updateStep, narMembers); buildRemote(destStore, machine, step, result, activeStep, updateStep, narMembers);
} catch (Error & e) { } catch (Error & e) {
if (activeStep->state_.lock()->cancelled) { if (activeStep->state_.lock()->cancelled) {
printInfo("marking step %d of build %d as cancelled", stepNr, buildId); printInfo("marking step %d of build %d as cancelled", stepNr, buildId);

View File

@@ -182,7 +182,7 @@ void State::monitorMachinesFile()
getEnv("NIX_REMOTE_SYSTEMS").value_or(pathExists(defaultMachinesFile) ? defaultMachinesFile : ""), ":"); getEnv("NIX_REMOTE_SYSTEMS").value_or(pathExists(defaultMachinesFile) ? defaultMachinesFile : ""), ":");
if (machinesFiles.empty()) { if (machinesFiles.empty()) {
parseMachines("localhost " + parseMachines("ssh-ng://localhost " +
(settings.thisSystem == "x86_64-linux" ? "x86_64-linux,i686-linux" : settings.thisSystem.get()) (settings.thisSystem == "x86_64-linux" ? "x86_64-linux,i686-linux" : settings.thisSystem.get())
+ " - " + std::to_string(settings.maxBuildJobs) + " 1 " + " - " + std::to_string(settings.maxBuildJobs) + " 1 "
+ concatStringsSep(",", StoreConfig::getDefaultSystemFeatures())); + concatStringsSep(",", StoreConfig::getDefaultSystemFeatures()));

View File

@@ -20,7 +20,7 @@
#include "store-api.hh" #include "store-api.hh"
#include "sync.hh" #include "sync.hh"
#include "nar-extractor.hh" #include "nar-extractor.hh"
#include "legacy-ssh-store.hh" #include "ssh-store.hh"
#include "machines.hh" #include "machines.hh"
@@ -294,12 +294,12 @@ struct Machine : nix::Machine
// Backpointer to the machine // Backpointer to the machine
ptr machine; ptr machine;
// Opened store // Opened store
nix::ref<nix::LegacySSHStore> store; nix::ref<nix::RemoteStore> store;
}; };
}; };
class HydraConfig; struct HydraConfig;
class State class State
@@ -542,7 +542,6 @@ private:
void buildRemote(nix::ref<nix::Store> destStore, void buildRemote(nix::ref<nix::Store> destStore,
Machine::ptr machine, Step::ptr step, Machine::ptr machine, Step::ptr step,
const nix::ServeProto::BuildOptions & buildOptions,
RemoteResult & result, std::shared_ptr<ActiveStep> activeStep, RemoteResult & result, std::shared_ptr<ActiveStep> activeStep,
std::function<void(StepState)> updateStep, std::function<void(StepState)> updateStep,
NarMemberDatas & narMembers); NarMemberDatas & narMembers);