about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorTeo Klestrup Röijezon <teo@nullable.se>2019-03-25 15:18:12 +0100
committerTeo Klestrup Röijezon <teo@nullable.se>2019-03-25 15:24:42 +0100
commit5eec83eb83045e8baf91df5c8181594781bc8658 (patch)
tree1175e7dcdd62cb980fea8a56ffde56cdb6f6125d /pkgs/build-support
parent072adccff7585b62b9ed74c08fe3cab0b117ed63 (diff)
downloadnixlib-5eec83eb83045e8baf91df5c8181594781bc8658.tar
nixlib-5eec83eb83045e8baf91df5c8181594781bc8658.tar.gz
nixlib-5eec83eb83045e8baf91df5c8181594781bc8658.tar.bz2
nixlib-5eec83eb83045e8baf91df5c8181594781bc8658.tar.lz
nixlib-5eec83eb83045e8baf91df5c8181594781bc8658.tar.xz
nixlib-5eec83eb83045e8baf91df5c8181594781bc8658.tar.zst
nixlib-5eec83eb83045e8baf91df5c8181594781bc8658.zip
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).
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/rust/build-rust-crate/helpers.nix3
1 files changed, 1 insertions, 2 deletions
diff --git a/pkgs/build-support/rust/build-rust-crate/helpers.nix b/pkgs/build-support/rust/build-rust-crate/helpers.nix
index 8a0a62434ec0..14d997b2d5cf 100644
--- a/pkgs/build-support/rust/build-rust-crate/helpers.nix
+++ b/pkgs/build-support/rust/build-rust-crate/helpers.nix
@@ -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: