diff options
author | tv <tv@shackspace.de> | 2015-10-17 06:16:56 +0200 |
---|---|---|
committer | tv <tv@shackspace.de> | 2015-10-17 06:16:56 +0200 |
commit | ad218104244578d705e45cd299c6dc4b3e0458b2 (patch) | |
tree | 8272f31c4cdf4e697205cf238540211a64d569a9 | |
parent | 421bf2ac0837e5652898ce7f7b983dc727fd5920 (diff) |
default out: simplify namespace loader
-rw-r--r-- | default.nix | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/default.nix b/default.nix index 0900ca7b2..b561cb7dd 100644 --- a/default.nix +++ b/default.nix @@ -23,29 +23,23 @@ let out = { inherit (eval {}) pkgs; } // - lib.mapAttrs (_: builtins.getAttr "main") - (lib.filterAttrs (_: builtins.hasAttr "main") - (lib.mapAttrs - (k: v: - if lib.hasPrefix "." k || v != "directory" then - {} - else if builtins.pathExists (./. + "/${k}/default.nix") then - { main = import (./. + "/${k}"); } - else if builtins.pathExists (./. + "/${k}/1systems") then - { main = mk-namespace (./. + "/${k}"); } - else - {}) - (builtins.readDir ./.))); + lib.mapAttrs + (name: _: + if builtins.pathExists (./. + "/${name}/default.nix") + then import (./. + "/${name}") + else import-1systems (./. + "/${name}/1systems")) + (lib.filterAttrs + (n: t: !lib.hasPrefix "." n && t == "directory") + (builtins.readDir ./.)); eval = path: import <nixpkgs/nixos/lib/eval-config.nix> { - system = builtins.currentSystem; modules = [ stockholm path ]; }; - mk-namespace = path: mapNixDir mk-system (path + "/1systems"); + import-1systems = path: lib.mapAttrs (_: mk-system) (nixDir path); mk-system = path: rec { inherit (eval path) config options; @@ -53,8 +47,6 @@ let fetch = import ./krebs/0tools/fetch.nix { inherit config lib; }; }; - mapNixDir = f: path: lib.mapAttrs (_: f) (nixDir path); - nixDir = path: builtins.listToAttrs (catMaybes |