about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
Diffstat (limited to 'tvix')
-rw-r--r--tvix/default.nix33
1 files changed, 21 insertions, 12 deletions
diff --git a/tvix/default.nix b/tvix/default.nix
index 12aabc9ded57..66d4a79d993a 100644
--- a/tvix/default.nix
+++ b/tvix/default.nix
@@ -1,21 +1,10 @@
 # Nix helpers for projects under //tvix
-{ pkgs, depot, ... }:
+{ pkgs, lib, depot, ... }:
 
 let
   # crate override for crates that need protobuf
   protobufDep = prev: (prev.nativeBuildInputs or [ ]) ++ [ pkgs.protobuf ];
 
-  # Cargo dependencies to be used with nixpkgs rustPlatform functions.
-  cargoDeps = pkgs.rustPlatform.importCargoLock {
-    lockFile = ./Cargo.lock;
-    outputHashes = {
-      "test-generator-0.3.0" = "08brp3qqa55hijc7xby3lam2cc84hvx1zzfqv6lj7smlczh8k32y";
-      "tonic-mock-0.1.0" = "0lwa03hpp0mxa6aa1zv5w68k61y4hccfm0q2ykyq392fwal8vb50";
-      "wu-manber-0.1.0" = "1zhk83lbq99xzyjwphv2qrb8f8qgfqwa5bbbvyzm0z0bljsjv0pd";
-    };
-  };
-in
-{
   # Load the crate2nix crate tree.
   crates = import ./Cargo.nix {
     inherit pkgs;
@@ -42,6 +31,26 @@ in
     };
   };
 
+  # Cargo dependencies to be used with nixpkgs rustPlatform functions.
+  cargoDeps = pkgs.rustPlatform.importCargoLock {
+    lockFile = ./Cargo.lock;
+    # Extract the hashes from `crates` / Cargo.nix, we already get them from cargo2nix.
+    # This returns an attribute set containing "${crateName}-${version}" as key,
+    # and the outputHash as value.
+    outputHashes = builtins.listToAttrs
+      (map
+        (crateName:
+          (lib.nameValuePair "${crateName}-${crates.internal.crates.${crateName}.version}" crates.internal.crates.${crateName}.src.outputHash)
+        ) [
+        "test-generator"
+        "tonic-mock"
+        "wu-manber"
+      ]);
+  };
+in
+{
+  inherit crates;
+
   # Run crate2nix generate in the current working directory, then
   # format the generated file with depotfmt.
   crate2nixGenerate = pkgs.writeShellScriptBin "crate2nix-generate" ''