From bb185b2c6eb8c4e035cddb61be772169df1b0139 Mon Sep 17 00:00:00 2001 From: Jürgen Hahn Date: Wed, 28 Dec 2022 10:28:37 +0100 Subject: feat(tvix/derivation): serialize Nix Derivation This adds a Derivation structure and allows to write it to a structure that implements std::fmt:Write. The implementation is based on the go-nix version. Change-Id: Ib54e1202b5c67f5d206b21bc109a751e971064cf Reviewed-on: https://cl.tvl.fyi/c/depot/+/7659 Reviewed-by: flokli Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/Cargo.nix | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'tvix/Cargo.nix') diff --git a/tvix/Cargo.nix b/tvix/Cargo.nix index 7d3c4c869196..fdc93f248b2d 100644 --- a/tvix/Cargo.nix +++ b/tvix/Cargo.nix @@ -33,6 +33,16 @@ rec { # You can override the features with # workspaceMembers."${crateName}".build.override { features = [ "default" "feature1" ... ]; }. workspaceMembers = { + "derivation" = rec { + packageId = "derivation"; + build = internal.buildRustCrateWithFeatures { + packageId = "derivation"; + }; + + # Debug support which might change between releases. + # File a bug if you depend on any for non-debug work! + debug = internal.debugCrate { inherit packageId; }; + }; "nix-cli" = rec { packageId = "nix-cli"; build = internal.buildRustCrateWithFeatures { @@ -1433,6 +1443,47 @@ rec { } ]; + }; + "derivation" = rec { + crateName = "derivation"; + version = "0.1.0"; + edition = "2021"; + # We can't filter paths with references in Nix 2.4 + # See https://github.com/NixOS/nix/issues/5410 + src = + if (lib.versionOlder builtins.nixVersion "2.4pre20211007") + then lib.cleanSourceWith { filter = sourceFilter; src = ./derivation; } + else ./derivation; + dependencies = [ + { + name = "blake3"; + packageId = "blake3"; + features = [ "rayon" "std" ]; + } + { + name = "maplit"; + packageId = "maplit"; + } + { + name = "prost"; + packageId = "prost"; + } + { + name = "tonic"; + packageId = "tonic"; + } + ]; + buildDependencies = [ + { + name = "prost-build"; + packageId = "prost-build"; + } + { + name = "tonic-build"; + packageId = "tonic-build"; + } + ]; + }; "diff" = rec { crateName = "diff"; @@ -2657,6 +2708,16 @@ rec { "value-bag" = [ "dep:value-bag" ]; }; }; + "maplit" = rec { + crateName = "maplit"; + version = "1.0.2"; + edition = "2015"; + sha256 = "07b5kjnhrrmfhgqm9wprjw8adx6i225lqp49gasgqg74lahnabiy"; + authors = [ + "bluss" + ]; + + }; "matchit" = rec { crateName = "matchit"; version = "0.7.0"; -- cgit 1.4.1