mirror of
https://github.com/divnix/digga.git
synced 2024-12-28 10:32:04 +03:00
9670fa4b0f
This reverts commit c9944b411e
.
Causes infinite recursion, revert for now while exploring possible
solutions.
24 lines
685 B
Nix
24 lines
685 B
Nix
{ lib, ... }:
|
|
let
|
|
inherit (builtins) attrNames isAttrs readDir;
|
|
|
|
inherit (lib) filterAttrs hasSuffix mapAttrs' nameValuePair removeSuffix;
|
|
|
|
in rec {
|
|
# mapFilterAttrs ::
|
|
# (name -> value -> bool )
|
|
# (name -> value -> { name = any; value = any; })
|
|
# attrs
|
|
mapFilterAttrs = seive: f: attrs: filterAttrs seive (mapAttrs' f attrs);
|
|
|
|
recImport = { dir, _import ? base: import "${dir}/${base}.nix" }:
|
|
mapFilterAttrs (_: v: v != null) (n: v:
|
|
if n != "default.nix" && hasSuffix ".nix" n && v == "regular"
|
|
|
|
then
|
|
let name = removeSuffix ".nix" n; in nameValuePair (name) (_import name)
|
|
|
|
else
|
|
nameValuePair ("") (null)) (readDir dir);
|
|
}
|