summaryrefslogtreecommitdiff
path: root/lib/importer.nix
blob: d74d6c9dfe99c6b2ef184e2cae6270146c06c02c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
lib: dir:
let
  nodes = builtins.readDir dir;

  shouldImport =
    name: type:
    let
      path = dir + "/${name}";
    in
    (type == "regular" && name != "default.nix" && lib.hasSuffix ".nix" name)
    || (type == "directory" && builtins.pathExists (path + "/default.nix"));

  validNodes = lib.filterAttrs shouldImport nodes;
in
map (name: dir + "/${name}") (builtins.attrNames validNodes)