1
1
mirror of https://github.com/divnix/digga.git synced 2024-12-23 16:11:51 +03:00
digga/attrs.nix
Pacman99 9f0ecf6920 init with devos lib extraction
simple copy of devos library code
2022-02-23 15:22:07 -08:00

20 lines
560 B
Nix

{ lib }:
rec {
# mapFilterAttrs ::
# (name -> value -> bool )
# (name -> value -> { name = any; value = any; })
# attrs
mapFilterAttrs = seive: f: attrs:
lib.filterAttrs
seive
(lib.mapAttrs' f attrs);
# Generate an attribute set by mapping a function over a list of values.
genAttrs' = values: f: lib.listToAttrs (map f values);
concatAttrs = lib.fold (attr: sum: lib.recursiveUpdate sum attr) { };
safeReadDir = path:
lib.optionalAttrs (builtins.pathExists (toString path)) (builtins.readDir (toString path));
}