Skip to content

Commit 7368fba

Browse files
Ericson2314Mic92
andcommitted
Bare minimum ssh-ng:// extensions for Hydra
This is not as comprehensive as #10748, but I am also interested in figuring out whether all those additions are in fact necessary. This is bare minimum needed for NixOS/hydra#1445, which has notable gaps but nevertheless reimplements enough with `ssh-ng://` to past all tests. I would like to merge this change as definitely necessary, and unclear whether sufficient. Then I would iterate on the corresponding Hydra PR until it seems potentially correct, seeing what, if any, further Nix API changes are necessary. Co-authored-by: Jörg Thalheim <[email protected]>
1 parent 2cfd031 commit 7368fba

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

src/libstore/remote-store.cc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,22 @@ BuildResult RemoteStore::buildDerivation(const StorePath & drvPath, const BasicD
767767
auto conn(getConnection());
768768
conn->putBuildDerivationRequest(*this, &conn.daemonException, drvPath, drv, buildMode);
769769
conn.processStderr();
770-
return WorkerProto::Serialise<BuildResult>::read(*this, *conn);
770+
return conn->getBuildDerivationResponse(*this, &conn.daemonException);
771+
}
772+
773+
774+
std::function<BuildResult()> RemoteStore::buildDerivationAsync(
775+
const StorePath & drvPath, const BasicDerivation & drv,
776+
BuildMode buildMode)
777+
{
778+
// Until we have C++23 std::move_only_function
779+
auto conn = std::make_shared<ConnectionHandle>(getConnection());
780+
(*conn)->putBuildDerivationRequest(*this, &conn->daemonException, drvPath, drv, buildMode);
781+
conn->processStderr();
782+
783+
return [this,conn]() -> BuildResult {
784+
return (*conn)->getBuildDerivationResponse(*this, &conn->daemonException);
785+
};
771786
}
772787

773788

src/libstore/remote-store.hh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ public:
122122
BuildResult buildDerivation(const StorePath & drvPath, const BasicDerivation & drv,
123123
BuildMode buildMode) override;
124124

125+
/**
126+
* Note, the returned function must only be called once, or we'll
127+
* try to read from the connection twice.
128+
*
129+
* This function is used by Hydra.
130+
*
131+
* @todo Use C++23 `std::move_only_function`.
132+
*/
133+
std::function<BuildResult()> buildDerivationAsync(
134+
const StorePath & drvPath, const BasicDerivation & drv,
135+
BuildMode buildMode);
136+
125137
void ensurePath(const StorePath & path) override;
126138

127139
void addTempRoot(const StorePath & path) override;

src/libstore/ssh-store.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ ref<RemoteStore::Connection> SSHStore::openConnection()
209209
}
210210
command.insert(command.end(),
211211
extraRemoteProgramArgs.begin(), extraRemoteProgramArgs.end());
212-
conn->sshConn = master.startCommand(std::move(command));
212+
conn->sshConn = master.startCommand(std::move(command), std::list{extraSshArgs});
213213
conn->to = FdSink(conn->sshConn->in.get());
214214
conn->from = FdSource(conn->sshConn->out.get());
215215
return conn;

src/libstore/ssh-store.hh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ struct SSHStoreConfig : virtual RemoteStoreConfig, virtual CommonSSHStoreConfig
1818
const Setting<Strings> remoteProgram{
1919
this, {"nix-daemon"}, "remote-program", "Path to the `nix-daemon` executable on the remote machine."};
2020

21+
/**
22+
* Hack for hydra
23+
*/
24+
Strings extraSshArgs = {};
25+
2126
const std::string name() override
2227
{
2328
return "Experimental SSH Store";

0 commit comments

Comments
 (0)