nix: filter source files

This speeds up the nix build by reducing the number of files that are copied to
the nix store.

Hopefully fixes #1095.
This commit is contained in:
Michael Forster 2023-01-26 18:51:25 +01:00 committed by Mike Forster
parent 29db607e10
commit 3ca26974e6

View file

@ -34,6 +34,15 @@
rust-overlay.overlays.default
];
};
filterSrc = src: regexes:
pkgs.lib.cleanSourceWith {
inherit src;
filter = path: type:
let
relPath = pkgs.lib.removePrefix (toString src + "/") (toString path);
in
pkgs.lib.all (re: builtins.match re relPath == null) regexes;
};
in
{
packages = {
@ -42,7 +51,12 @@
version = "unstable-${self.shortRev or "dirty"}";
buildNoDefaultFeatures = true;
buildFeatures = [ "jujutsu-lib/legacy-thrift" ];
src = ./.;
src = filterSrc ./. [
".*\\.nix$"
"^.jj/"
"^flake\\.lock$"
"^target/"
];
cargoLock = {
lockFile = ./Cargo.lock;
};