From ad218104244578d705e45cd299c6dc4b3e0458b2 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 17 Oct 2015 06:16:56 +0200 Subject: default out: simplify namespace loader --- default.nix | 26 +++++++++----------------- 1 file 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 { - 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 -- cgit v1.2.3