about summary refs log tree commit diff
path: root/tvix/utils.nix
diff options
context:
space:
mode:
authorIlan Joselevich <personal@ilanjoselevich.com>2024-07-04T19·02+0300
committerIlan Joselevich <personal@ilanjoselevich.com>2024-07-05T20·19+0000
commit6a7069904e9d29f05638c37a52b640bc9eb43a63 (patch)
tree1bc52b6a79dcce1aeba24ba31a9a32ff7840ccd2 /tvix/utils.nix
parent63654fbeb16278e21b8c5131fb402c7c98da5489 (diff)
feat(tvix/utils): Add defaultCrateOverridesForPkgs function r/8348
This function can be reused across the rest of the repo to make use of
our overriden defaultCrateOverrides with support for tvix crates.

Change-Id: I8c554dece052bd9dd32acac13dab8114933272a7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11951
Autosubmit: Ilan Joselevich <personal@ilanjoselevich.com>
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to '')
-rw-r--r--tvix/utils.nix77
1 files changed, 77 insertions, 0 deletions
diff --git a/tvix/utils.nix b/tvix/utils.nix
index 0bb9323d68..7adf8fe997 100644
--- a/tvix/utils.nix
+++ b/tvix/utils.nix
@@ -41,4 +41,81 @@
           (lib.fileset.maybeMissing (root + "/Cargo.lock"))
         ] ++ lib.optional (extraFileset != null) extraFileset));
     };
+
+  # A function which takes a pkgs instance and returns an overriden defaultCrateOverrides with support for tvix crates.
+  # This can be used throughout the rest of the repo.
+  defaultCrateOverridesForPkgs = pkgs:
+    let
+      commonDarwinDeps = with pkgs.darwin.apple_sdk.frameworks; [
+        Security
+        SystemConfiguration
+      ];
+    in
+    pkgs.defaultCrateOverrides // {
+      nix-compat = prev: {
+        src = depot.tvix.utils.filterRustCrateSrc rec {
+          root = prev.src.origSrc;
+          extraFileset = root + "/testdata";
+        };
+      };
+      tvix-build = prev: {
+        src = depot.tvix.utils.filterRustCrateSrc rec {
+          root = prev.src.origSrc;
+          extraFileset = lib.fileset.fileFilter (f: f.hasExt "proto") root;
+        };
+        PROTO_ROOT = depot.tvix.build.protos.protos;
+        nativeBuildInputs = [ pkgs.protobuf ];
+        buildInputs = lib.optional pkgs.stdenv.isDarwin commonDarwinDeps;
+      };
+
+      tvix-castore = prev: {
+        src = depot.tvix.utils.filterRustCrateSrc rec {
+          root = prev.src.origSrc;
+          extraFileset = lib.fileset.fileFilter (f: f.hasExt "proto") root;
+        };
+        PROTO_ROOT = depot.tvix.castore.protos.protos;
+        nativeBuildInputs = [ pkgs.protobuf ];
+      };
+
+      tvix-cli = prev: {
+        src = depot.tvix.utils.filterRustCrateSrc { root = prev.src.origSrc; };
+        buildInputs = lib.optional pkgs.stdenv.isDarwin commonDarwinDeps;
+      };
+
+      tvix-store = prev: {
+        src = depot.tvix.utils.filterRustCrateSrc rec {
+          root = prev.src.origSrc;
+          extraFileset = lib.fileset.fileFilter (f: f.hasExt "proto") root;
+        };
+        PROTO_ROOT = depot.tvix.store.protos.protos;
+        nativeBuildInputs = [ pkgs.protobuf ];
+        # fuse-backend-rs uses DiskArbitration framework to handle mount/unmount on Darwin
+        buildInputs = lib.optional pkgs.stdenv.isDarwin (commonDarwinDeps ++ pkgs.darwin.apple_sdk.frameworks.DiskArbitration);
+      };
+
+      tvix-eval-builtin-macros = prev: {
+        src = depot.tvix.utils.filterRustCrateSrc { root = prev.src.origSrc; };
+      };
+
+      tvix-eval = prev: {
+        src = depot.tvix.utils.filterRustCrateSrc rec {
+          root = prev.src.origSrc;
+          extraFileset = root + "/proptest-regressions";
+        };
+      };
+
+      tvix-glue = prev: {
+        src = depot.tvix.utils.filterRustCrateSrc {
+          root = prev.src.origSrc;
+        };
+      };
+
+      tvix-serde = prev: {
+        src = depot.tvix.utils.filterRustCrateSrc { root = prev.src.origSrc; };
+      };
+
+      tvix-tracing = prev: {
+        src = depot.tvix.utils.filterRustCrateSrc { root = prev.src.origSrc; };
+      };
+    };
 }