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).
This commit is contained in:
Teo Klestrup Röijezon 2019-03-25 15:18:12 +01:00
parent 072adccff7
commit 5eec83eb83

View File

@ -14,9 +14,8 @@
include = includedFiles: src: builtins.filterSource (path: type:
lib.lists.any (f:
let p = toString (src + ("/" + f));
suff = lib.strings.removePrefix p path;
in
suff == "" || (lib.strings.hasPrefix "/" suff)
p == path || (lib.strings.hasPrefix (p + "/") path)
) includedFiles
) src;
exclude = excludedFiles: src: builtins.filterSource (path: type: