mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-29 00:53:57 +00:00
5eec83eb83
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).
27 lines
995 B
Nix
27 lines
995 B
Nix
{stdenv, lib}:
|
|
{
|
|
kernel = stdenv.hostPlatform.parsed.kernel.name;
|
|
abi = stdenv.hostPlatform.parsed.abi.name;
|
|
cpu = stdenv.hostPlatform.parsed.cpu.name;
|
|
updateFeatures = f: up: functions: builtins.deepSeq f (lib.lists.foldl' (features: fun: fun features) (lib.attrsets.recursiveUpdate f up) functions);
|
|
mapFeatures = features: map (fun: fun { features = features; });
|
|
mkFeatures = feat: lib.lists.foldl (features: featureName:
|
|
if feat.${featureName} or false then
|
|
[ featureName ] ++ features
|
|
else
|
|
features
|
|
) [] (builtins.attrNames feat);
|
|
include = includedFiles: src: builtins.filterSource (path: type:
|
|
lib.lists.any (f:
|
|
let p = toString (src + ("/" + f));
|
|
in
|
|
p == path || (lib.strings.hasPrefix (p + "/") path)
|
|
) includedFiles
|
|
) src;
|
|
exclude = excludedFiles: src: builtins.filterSource (path: type:
|
|
lib.lists.all (f:
|
|
!lib.strings.hasPrefix (toString (src + ("/" + f))) path
|
|
) excludedFiles
|
|
) src;
|
|
}
|