1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-25 03:17:13 +00:00
nixpkgs/pkgs/build-support/rust/build-rust-crate/helpers.nix

27 lines
961 B
Nix
Raw Normal View History

{stdenv, lib}:
{
kernel = stdenv.hostPlatform.parsed.kernel.name;
abi = stdenv.hostPlatform.parsed.abi.name;
2018-11-22 11:40:03 +00:00
cpu = stdenv.hostPlatform.parsed.cpu.name;
updateFeatures = f: up: functions: lib.deepSeq f (lib.foldl' (features: fun: fun features) (lib.attrsets.recursiveUpdate f up) functions);
mapFeatures = features: map (fun: fun { features = features; });
mkFeatures = feat: lib.foldl (features: featureName:
if feat.${featureName} or false then
[ featureName ] ++ features
else
features
) [] (lib.attrNames feat);
include = includedFiles: src: builtins.filterSource (path: type:
lib.any (f:
2018-11-22 11:40:03 +00:00
let p = toString (src + ("/" + f));
in
p == path || (lib.strings.hasPrefix (p + "/") path)
2018-11-22 11:40:03 +00:00
) includedFiles
) src;
exclude = excludedFiles: src: builtins.filterSource (path: type:
lib.all (f:
!lib.strings.hasPrefix (toString (src + ("/" + f))) path
) excludedFiles
) src;
}