From 57d47a36129b459f0fac519a460c581870a54bbf Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 13 Nov 2026 23:32:57 +0000 Subject: 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. --- pkgs/populate/program.nix | 13 +++++++------ 1 file 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; } -- cgit v1.3.1