Skip to content

Commit

Permalink
build(nix): filter src to reduce useless rebuilds
Browse files Browse the repository at this point in the history
This in particular speeds up the dev/run/debug cycle for writing more
tests. Without this, the actual bcachefs-tools package will be rebuilt
by Nix all the time because of changes to files that are tracked by git.
Even when it's changes in parts that aren't relevant to that package
build such as `checks/*`.

Signed-off-by: Thomas Mühlbacher <[email protected]>
  • Loading branch information
tmuehlbacher committed Jun 18, 2024
1 parent 01a802b commit 2992f7d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
16 changes: 16 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
inputs.nixpkgs.follows = "nixpkgs";
};

nix-filter.url = "github:numtide/nix-filter";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
Expand All @@ -33,6 +35,7 @@
nixpkgs,
flake-parts,
treefmt-nix,
nix-filter,
fenix,
crane,
...
Expand Down Expand Up @@ -64,6 +67,8 @@
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
rustfmtToml = builtins.fromTOML (builtins.readFile ./rustfmt.toml);

filter = nix-filter.lib;

craneLib = crane.mkLib pkgs;

rev = self.shortRev or self.dirtyShortRev or (substring 0 8 self.lastModifiedDate);
Expand All @@ -74,7 +79,14 @@

commonArgs = {
inherit version;
src = self;
src = filter {
root = self;
exclude = [
"checks"
"doc"
"tests"
];
};

env = {
PKG_CONFIG_SYSTEMD_SYSTEMDSYSTEMUNITDIR = "${placeholder "out"}/lib/systemd/system";
Expand Down

0 comments on commit 2992f7d

Please sign in to comment.