cleanSourceWith
lib.sources.cleanSourceWith
Docs pulled from | This Revision | about 1 hour ago
Like builtins.filterSource, except it will compose with itself,
allowing you to chain multiple calls together without any
intermediate copies being put in the nix store.
Examples
cleanSourceWith usage example
lib.cleanSourceWith {
filter = f;
src = lib.cleanSourceWith {
filter = g;
src = ./.;
};
}
# Succeeds!
builtins.filterSource f (builtins.filterSource g ./.)
# Fails!
Noogle detected
Implementation
The following is the current implementation of this function.
cleanSourceWith =
{
# A path or cleanSourceWith result to filter and/or rename.
src,
# Optional with default value: constant true (include everything)
# The function will be combined with the && operator such
# that src.filter is called lazily.
# For implementing a filter, see
# https://nixos.org/nix/manual/#builtin-filterSource
# Type: A function (path -> type -> bool)
filter ? _path: _type: true,
# Optional name to use as part of the store path.
# This defaults to `src.name` or otherwise `"source"`.
name ? null,
}:
let
orig = toSourceAttributes src;
in
fromSourceAttributes {
inherit (orig) origSrc;
filter = path: type: filter path type && orig.filter path type;
name = if name != null then name else orig.name;
};