feat(3p/nix/nix-daemon): Implement Worker::BuildDerivation handler
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>
This commit is contained in:
parent
3f4e5050cd
commit
a79df261b4
6 changed files with 133 additions and 1 deletions
9
third_party/nix/src/libstore/store-api.hh
vendored
9
third_party/nix/src/libstore/store-api.hh
vendored
|
|
@ -8,6 +8,7 @@
|
|||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "libproto/worker.pb.h"
|
||||
#include "libstore/crypto.hh"
|
||||
#include "libstore/globals.hh"
|
||||
#include "libutil/config.hh"
|
||||
|
|
@ -181,6 +182,10 @@ typedef std::list<ValidPathInfo> ValidPathInfos;
|
|||
|
||||
enum BuildMode { bmNormal, bmRepair, bmCheck };
|
||||
|
||||
// Convert the proto version of a `nix::proto::BuildMode` to its corresponding
|
||||
// nix `BuildMode`
|
||||
std::optional<BuildMode> build_mode_from(nix::proto::BuildMode mode);
|
||||
|
||||
struct BuildResult {
|
||||
/* Note: don't remove status codes, and only add new status codes
|
||||
at the end of the list, to prevent client/server
|
||||
|
|
@ -218,6 +223,10 @@ struct BuildResult {
|
|||
bool success() {
|
||||
return status == Built || status == Substituted || status == AlreadyValid;
|
||||
}
|
||||
|
||||
// Convert the status of this `BuildResult` to its corresponding
|
||||
// `nix::proto::BuildStatus`
|
||||
nix::proto::BuildStatus status_to_proto();
|
||||
};
|
||||
|
||||
class Store : public std::enable_shared_from_this<Store>, public Config {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue