Skip to content

Commit

Permalink
Factor out ServeProto::BasicClientConnection::buildDerivationRequest
Browse files Browse the repository at this point in the history
For Hydra.
  • Loading branch information
Ericson2314 committed Dec 7, 2023
1 parent 189d096 commit c114859
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/libstore/legacy-ssh-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,16 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor

private:

void putBuildSettings(Connection & conn)
ServeProto::BasicClientConnection::BuildOptions buildSettings()
{
conn.putBuildSettings({
return {
.maxSilentTime = settings.maxSilentTime,
.buildTimeout = settings.buildTimeout,
.repeats = 0, // buildRepeat hasn't worked for ages anyway
.maxLogSize = settings.maxLogSize,
.enforceDeterminism = 0,
.keepFailed = settings.keepFailed,
});
};
}

public:
Expand All @@ -257,14 +257,7 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor
{
auto conn(connections->get());

conn->to
<< ServeProto::Command::BuildDerivation
<< printStorePath(drvPath);
writeDerivation(conn->to, *this, drv);

putBuildSettings(*conn);

conn->to.flush();
conn->buildDerivationRequest(*this, drvPath, drv, buildSettings());

return ServeProto::Serialise<BuildResult>::read(*this, *conn);
}
Expand Down Expand Up @@ -294,7 +287,7 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor
}
conn->to << ss;

putBuildSettings(*conn);
conn->putBuildSettings(buildSettings());

conn->to.flush();

Expand Down
18 changes: 18 additions & 0 deletions src/libstore/serve-protocol-impl.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "serve-protocol-impl.hh"
#include "build-result.hh"
#include "derivations.hh"

namespace nix {

Expand Down Expand Up @@ -36,4 +38,20 @@ void ServeProto::BasicClientConnection::putBuildSettings(
}
}


void ServeProto::BasicClientConnection::buildDerivationRequest(
const Store & store,
const StorePath & drvPath, const BasicDerivation & drv,
const ServeProto::BasicClientConnection::BuildOptions & options)
{
to
<< ServeProto::Command::BuildDerivation
<< store.printStorePath(drvPath);
writeDerivation(to, store, drv);

putBuildSettings(options);

to.flush();
}

}
9 changes: 9 additions & 0 deletions src/libstore/serve-protocol-impl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ struct ServeProto::BasicClientConnection
};

void putBuildSettings(const BuildOptions & options);

/**
* Just the request half, because Hydra may do other things between
* issuing the request and reading the `BuildResult` response.
*/
void buildDerivationRequest(
const Store & store,
const StorePath & drvPath, const BasicDerivation & drv,
const ServeProto::BasicClientConnection::BuildOptions & options);
};

}

0 comments on commit c114859

Please sign in to comment.