From 084c8642db13b93ed6bd0b6808bcd16c8dfeaf99 Mon Sep 17 00:00:00 2001 From: figsoda Date: Wed, 28 Jun 2023 06:32:21 -0400 Subject: [PATCH] Reduce rebuilds for the Nix flake (#1586) This makes it so the package doesn't need to be rebuilt when unrelated changes happen, e.g. in README --- flake.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 861ddd208..437936bd3 100644 --- a/flake.nix +++ b/flake.nix @@ -13,7 +13,7 @@ genAttrs importTOML optionals - cleanSource + sourceByRegex ; eachSystem = f: genAttrs @@ -25,9 +25,6 @@ ] (system: f nixpkgs.legacyPackages.${system}); - rev = fallback: - self.shortRev or fallback; - packageFor = pkgs: let rust = fenix.packages.${pkgs.stdenv.hostPlatform.system}.minimal.toolchain; @@ -36,11 +33,15 @@ rustc = rust; }; in - rustPlatform.buildRustPackage rec { + rustPlatform.buildRustPackage { pname = "typst"; inherit ((importTOML ./Cargo.toml).workspace.package) version; - src = cleanSource ./.; + src = sourceByRegex ./. [ + "(assets|cli|docs|library|macros|src|tests)(/.*)?" + ''Cargo\.(toml|lock)'' + ''build\.rs'' + ]; cargoLock = { lockFile = ./Cargo.lock; @@ -63,7 +64,6 @@ ''; GEN_ARTIFACTS = "artifacts"; - TYPST_VERSION = "${version} (${rev "unknown hash"})"; }; in {