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
This commit is contained in:
figsoda 2023-06-28 06:32:21 -04:00 committed by GitHub
parent c44bad5739
commit 084c8642db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
{