about summary refs log tree commit diff
path: root/tvix/Cargo.nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-12-31T15·13+0300
committertazjin <tazjin@tvl.su>2023-01-02T22·24+0000
commit90c32eec7a382195e6d533c6e55a3d20c58cc3a5 (patch)
tree81f70eb9ab9eb621ab9a6d11d3951a58292cf28c /tvix/Cargo.nix
parent49ee3e3b148c1edb74a15e26eacb5911647d1de5 (diff)
feat(tvix/serde): initial Nix->serde::Deserialize impl r/5566
This will make it possible fairly easily use Nix to represent
arbitrary data structures, e.g. for using Nix as a config language.

Only pure Nix (i.e. no `import` etc.) is supported for now.

Not all types, specifically no struct traversal, are implemented in
this commit.

Change-Id: I9ac91a229a0d12bf818e6e3249f3e5a691599a2c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7712
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/Cargo.nix')
-rw-r--r--tvix/Cargo.nix32
1 files changed, 32 insertions, 0 deletions
diff --git a/tvix/Cargo.nix b/tvix/Cargo.nix
index 57b5e2a0ff6a..361a0a3ee033 100644
--- a/tvix/Cargo.nix
+++ b/tvix/Cargo.nix
@@ -93,6 +93,16 @@ rec {
       # File a bug if you depend on any for non-debug work!
       debug = internal.debugCrate { inherit packageId; };
     };
+    "tvix-serde" = rec {
+      packageId = "tvix-serde";
+      build = internal.buildRustCrateWithFeatures {
+        packageId = "tvix-serde";
+      };
+
+      # Debug support which might change between releases.
+      # File a bug if you depend on any for non-debug work!
+      debug = internal.debugCrate { inherit packageId; };
+    };
     "tvix-store" = rec {
       packageId = "tvix-store";
       build = internal.buildRustCrateWithFeatures {
@@ -6609,6 +6619,28 @@ rec {
           else ./nar;
 
       };
+      "tvix-serde" = rec {
+        crateName = "tvix-serde";
+        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 = ./serde; }
+          else ./serde;
+        dependencies = [
+          {
+            name = "serde";
+            packageId = "serde";
+          }
+          {
+            name = "tvix-eval";
+            packageId = "tvix-eval";
+          }
+        ];
+
+      };
       "tvix-store" = rec {
         crateName = "tvix-store";
         version = "0.1.0";