about summary refs log tree commit diff
path: root/tvix/default.nix
diff options
context:
space:
mode:
authorIlan Joselevich <personal@ilanjoselevich.com>2024-06-17T13·34+0300
committerIlan Joselevich <personal@ilanjoselevich.com>2024-06-17T15·26+0000
commit92c5433304ebd0614fa49e7a6608521d23789764 (patch)
tree7275c98aa84c397263222baee8faa0cb3307baee /tvix/default.nix
parentac51803ad85853aae64c1f4c12ad0688002cbaa2 (diff)
chore(tvix): move filterRustCrateSrc to utils.nix r/8293
Change-Id: Ib6bae1ea0457d3309a6ec1e08b9e4b320523c161
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11857
Autosubmit: Ilan Joselevich <personal@ilanjoselevich.com>
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/default.nix')
-rw-r--r--tvix/default.nix39
1 files changed, 10 insertions, 29 deletions
diff --git a/tvix/default.nix b/tvix/default.nix
index 887e9f90fdb1..efbaf54f46c4 100644
--- a/tvix/default.nix
+++ b/tvix/default.nix
@@ -11,25 +11,6 @@ let
     SystemConfiguration
   ]);
 
-  # Filters the given source, only keeping files related to the build, preventing unnecessary rebuilds.
-  # Includes src in the root, all other .rs files, as well as Cargo.toml.
-  # Additional files to be included can be specified in extraFileset.
-  filterRustCrateSrc =
-    { root # The original src
-    , extraFileset ? null # Additional filesets to include (e.g. fileFilter for proto files)
-    }:
-    lib.fileset.toSource {
-      inherit root;
-      fileset = (lib.fileset.intersection
-        (lib.fileset.fromSource root) # We build our final fileset from the original src
-        (lib.fileset.unions ([
-          (root + "/src")
-          (lib.fileset.fileFilter (f: f.hasExt "rs") root)
-          # We assume that every Rust crate will at a minimum have .rs files and a Cargo.toml
-          (lib.fileset.fileFilter (f: f.name == "Cargo.toml") root)
-        ] ++ lib.optional (extraFileset != null) extraFileset)));
-    };
-
   # Load the crate2nix crate tree.
   crates = pkgs.callPackage ./Cargo.nix {
     defaultCrateOverrides = pkgs.defaultCrateOverrides // {
@@ -50,7 +31,7 @@ let
       };
 
       tvix-build = prev: {
-        src = filterRustCrateSrc rec {
+        src = depot.tvix.utils.filterRustCrateSrc rec {
           root = prev.src.origSrc;
           extraFileset = (lib.fileset.fileFilter (f: f.hasExt "proto") root);
         };
@@ -60,7 +41,7 @@ let
       };
 
       tvix-castore = prev: {
-        src = filterRustCrateSrc rec {
+        src = depot.tvix.utils.filterRustCrateSrc rec {
           root = prev.src.origSrc;
           extraFileset = (lib.fileset.fileFilter (f: f.hasExt "proto") root);
         };
@@ -69,12 +50,12 @@ let
       };
 
       tvix-cli = prev: {
-        src = filterRustCrateSrc { root = prev.src.origSrc; };
+        src = depot.tvix.utils.filterRustCrateSrc { root = prev.src.origSrc; };
         buildInputs = prev.buildInputs or [ ] ++ darwinDeps;
       };
 
       tvix-store = prev: {
-        src = filterRustCrateSrc rec {
+        src = depot.tvix.utils.filterRustCrateSrc rec {
           root = prev.src.origSrc;
           extraFileset = (lib.fileset.fileFilter (f: f.hasExt "proto") root);
         };
@@ -87,32 +68,32 @@ let
       };
 
       tvix-eval-builtin-macros = prev: {
-        src = filterRustCrateSrc { root = prev.src.origSrc; };
+        src = depot.tvix.utils.filterRustCrateSrc { root = prev.src.origSrc; };
       };
 
       tvix-eval = prev: {
-        src = filterRustCrateSrc rec {
+        src = depot.tvix.utils.filterRustCrateSrc rec {
           root = prev.src.origSrc;
           extraFileset = (root + "/proptest-regressions");
         };
       };
 
       tvix-glue = prev: {
-        src = filterRustCrateSrc {
+        src = depot.tvix.utils.filterRustCrateSrc {
           root = prev.src.origSrc;
         };
       };
 
       tvix-serde = prev: {
-        src = filterRustCrateSrc { root = prev.src.origSrc; };
+        src = depot.tvix.utils.filterRustCrateSrc { root = prev.src.origSrc; };
       };
 
       tvix-tracing = prev: {
-        src = filterRustCrateSrc { root = prev.src.origSrc; };
+        src = depot.tvix.utils.filterRustCrateSrc { root = prev.src.origSrc; };
       };
 
       nix-compat = prev: {
-        src = filterRustCrateSrc rec {
+        src = depot.tvix.utils.filterRustCrateSrc rec {
           root = prev.src.origSrc;
           extraFileset = (root + "/testdata");
         };