diff options
| author | tv <tv@krebsco.de> | 2026-11-13 23:32:57 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-14 00:35:18 +0100 |
| commit | 57d47a36129b459f0fac519a460c581870a54bbf (patch) | |
| tree | c38491bc48d7dda1c47352f97fd2cd4cc1ec634a | |
| parent | 694e3623572628d831fecb78269a882d0268bd0d (diff) | |
populate: filter the program's sources by name
The filter for the program's sources took the paths it gets relative
to toString ./., which they needn't start with, e.g. if a symlink leads
to the directory, so nothing matched, and the build found no
Cargo.lock. It goes by the names of what it leaves out now: the Nix
files, the docs, .gitignore, and cargo's target directory.
| -rw-r--r-- | pkgs/populate/program.nix | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pkgs/populate/program.nix b/pkgs/populate/program.nix index 06cfa07..fbb364c 100644 --- a/pkgs/populate/program.nix +++ b/pkgs/populate/program.nix @@ -8,17 +8,18 @@ in rustPlatform.buildRustPackage { pname = cargoToml.package.name; inherit (cargoToml.package) version; - # Only what cargo builds from, so changes to the Nix files or the docs - # don't rebuild the program. + # Without what cargo doesn't build from, so changes to the Nix files or + # the docs don't rebuild the program. By names, not by paths relative to + # this directory: the paths the filter gets needn't start with + # toString ./., e.g. if a symlink leads to this directory. src = builtins.path { name = "populate-src"; path = ./.; filter = path: type: let - relative = builtins.substring - (builtins.stringLength (toString ./.) + 1) (-1) (toString path); + name = baseNameOf path; in - builtins.elem relative [ "Cargo.toml" "Cargo.lock" "src" ] || - builtins.substring 0 4 relative == "src/"; + !(builtins.elem name [ ".gitignore" "docs" "target" ] || + builtins.match ".*\\.nix" name != null); }; cargoLock.lockFile = ./Cargo.lock; } |
