diff options
author | Griffin Smith <grfn@gws.fyi> | 2020-07-17T13·30-0400 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2020-07-18T19·52+0000 |
commit | a79df261b498473ae7c6d4a04f32c50d5954124f (patch) | |
tree | 1758dd00cc3c541cd67801bd30cbef8c62aca593 /third_party/nix/src/libstore/derivations.cc | |
parent | 3f4e5050cd046c137ff6d0a1bd046c5494f60471 (diff) |
feat(3p/nix/nix-daemon): Implement Worker::BuildDerivation handler r/1382
Implement the proto handler on the server side for Worker::BuildDerivation. This includes several additions to the proto which I had missed on the first pass, including the actual proto definition for the Derivation itself and a few sequence number reorderings which are fine because this is all provisional and not deployed yet. A couple things to note - I implemented a couple constructors for nix classes that initialize themselves based on their proto variants, which felt nice and didn't end up causing any issues. - I've made the conversions between the enum types in nix and in proto explicit via switch statements rather than using a static_cast, out of an abundance of caution that the error would get mismatched in the future and we'd convert the wrong thing to the wrong thing - this is verbose, but exceptionally future proof. Change-Id: Iecf6b88e76bc37e49efa05fd65d6cd0cb0deffed Reviewed-on: https://cl.tvl.fyi/c/depot/+/1249 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in> Reviewed-by: Kane York <rikingcoding@gmail.com>
Diffstat (limited to 'third_party/nix/src/libstore/derivations.cc')
-rw-r--r-- | third_party/nix/src/libstore/derivations.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/third_party/nix/src/libstore/derivations.cc b/third_party/nix/src/libstore/derivations.cc index 59b2a505a307..419fc584f1fe 100644 --- a/third_party/nix/src/libstore/derivations.cc +++ b/third_party/nix/src/libstore/derivations.cc @@ -30,6 +30,28 @@ void DerivationOutput::parseHashInfo(bool& recursive, Hash& hash) const { hash = Hash(this->hash, hashType); } +BasicDerivation BasicDerivation::from_proto( + const nix::proto::Derivation* proto_derivation, const nix::Store* store) { + BasicDerivation result; + result.platform = proto_derivation->platform(); + result.builder = proto_derivation->builder().path(); + store->assertStorePath(result.builder); + + result.outputs.insert(proto_derivation->outputs().begin(), + proto_derivation->outputs().end()); + + result.inputSrcs.insert(proto_derivation->input_sources().paths().begin(), + proto_derivation->input_sources().paths().end()); + + result.args.insert(result.args.end(), proto_derivation->args().begin(), + proto_derivation->args().end()); + + result.env.insert(proto_derivation->env().begin(), + proto_derivation->env().end()); + + return result; +} + Path BasicDerivation::findOutput(const std::string& id) const { auto i = outputs.find(id); if (i == outputs.end()) { |