Skip to content

Commit

Permalink
Factor out ServeProto::BasicClientConnection::buildDerivation
Browse files Browse the repository at this point in the history
For Hydra.
  • Loading branch information
Ericson2314 committed Dec 7, 2023
1 parent 9312fe9 commit bbeffc9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/libstore/legacy-ssh-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,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 @@ -269,16 +269,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();

return ServeProto::Serialise<BuildResult>::read(*this, *conn);
return conn->buildDerivation(*this, drvPath, drv, buildSettings());
}

void buildPaths(const std::vector<DerivedPath> & drvPaths, BuildMode buildMode, std::shared_ptr<Store> evalStore) override
Expand Down Expand Up @@ -306,7 +297,7 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor
}
conn->to << ss;

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

conn->to.flush();

Expand Down
20 changes: 20 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,22 @@ void ServeProto::BasicClientConnection::putBuildSettings(
}
}


BuildResult ServeProto::BasicClientConnection::buildDerivation(
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();

return ServeProto::Serialise<BuildResult>::read(store, *this);
}

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

void putBuildSettings(const BuildOptions & options);

BuildResult buildDerivation(
const Store & store,
const StorePath & drvPath, const BasicDerivation & drv,
const ServeProto::BasicClientConnection::BuildOptions & options);
};

}

0 comments on commit bbeffc9

Please sign in to comment.