default out: simplify namespace loader

This commit is contained in:
tv 2015-10-17 06:16:56 +02:00
parent 421bf2ac08
commit ad21810424
1 changed files with 9 additions and 17 deletions

View File

@ -23,29 +23,23 @@ let
out = out =
{ inherit (eval {}) pkgs; } // { inherit (eval {}) pkgs; } //
lib.mapAttrs (_: builtins.getAttr "main") lib.mapAttrs
(lib.filterAttrs (_: builtins.hasAttr "main") (name: _:
(lib.mapAttrs if builtins.pathExists (./. + "/${name}/default.nix")
(k: v: then import (./. + "/${name}")
if lib.hasPrefix "." k || v != "directory" then else import-1systems (./. + "/${name}/1systems"))
{} (lib.filterAttrs
else if builtins.pathExists (./. + "/${k}/default.nix") then (n: t: !lib.hasPrefix "." n && t == "directory")
{ main = import (./. + "/${k}"); } (builtins.readDir ./.));
else if builtins.pathExists (./. + "/${k}/1systems") then
{ main = mk-namespace (./. + "/${k}"); }
else
{})
(builtins.readDir ./.)));
eval = path: import <nixpkgs/nixos/lib/eval-config.nix> { eval = path: import <nixpkgs/nixos/lib/eval-config.nix> {
system = builtins.currentSystem;
modules = [ modules = [
stockholm stockholm
path path
]; ];
}; };
mk-namespace = path: mapNixDir mk-system (path + "/1systems"); import-1systems = path: lib.mapAttrs (_: mk-system) (nixDir path);
mk-system = path: rec { mk-system = path: rec {
inherit (eval path) config options; inherit (eval path) config options;
@ -53,8 +47,6 @@ let
fetch = import ./krebs/0tools/fetch.nix { inherit config lib; }; fetch = import ./krebs/0tools/fetch.nix { inherit config lib; };
}; };
mapNixDir = f: path: lib.mapAttrs (_: f) (nixDir path);
nixDir = path: nixDir = path:
builtins.listToAttrs builtins.listToAttrs
(catMaybes (catMaybes