core/pkgs/build-support/rust/build-rust-crate/helpers.nix

36 lines
1,021 B
Nix
Raw Normal View History

2024-06-30 08:16:52 +00:00
{ stdenv, lib }:
2024-05-02 00:46:19 +00:00
{
kernel = stdenv.hostPlatform.parsed.kernel.name;
abi = stdenv.hostPlatform.parsed.abi.name;
cpu = stdenv.hostPlatform.parsed.cpu.name;
2024-06-30 08:16:52 +00:00
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:
let
p = toString (src + ("/" + f));
in
p == path || (lib.strings.hasPrefix (p + "/") path)
) includedFiles
) src;
exclude =
excludedFiles: src:
builtins.filterSource (
path: type: lib.all (f: !lib.strings.hasPrefix (toString (src + ("/" + f))) path) excludedFiles
) src;
2024-05-02 00:46:19 +00:00
}