git.iko.soy/typeable/nixpkgs
on master help sign in
buildRustCrate: Fix `include` filter

buildRustCrate has a handy `include` helper, that only imports those whitelisted files and folders to the store. However, the function's matching logic is broken and includes all files, regardless of whether or not they're whitelisted, as long as the whitelist contains at least one name (regardless of whether that name exists). This is because it doesn't take into account that `lib.strings.removePrefix "foo" "bar" == "bar"` (that is, paths that don't match the prefix are passed straight through).

commit5eec83eb83045e8baf91df5c8181594781bc8658 authorTeo Klestrup Röijezon <teo@nullable.se> dateMon 25 Mar 2019, 15:18 (8 years ago) parent072adcc
1 file changed+1−2
pkgs/build-support/rust/build-rust-crate/helpers.nix+1−2
pkgs/build-support/rust/build-rust-crate/helpers.nix+1−2
@@ -14,9 +14,8 @@
1414 include = includedFiles: src: builtins.filterSource (path: type:
1515 lib.lists.any (f:
1616 let p = toString (src + ("/" + f));
17− suff = lib.strings.removePrefix p path;
1817 in
19− suff == "" || (lib.strings.hasPrefix "/" suff)
18+ p == path || (lib.strings.hasPrefix (p + "/") path)
2019 ) includedFiles
2120 ) src;
2221 exclude = excludedFiles: src: builtins.filterSource (path: type: