From 15c6f0678fad4bb7541338e4f422e8a913d616f9 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 17 Oct 2015 05:44:42 +0200 Subject: explicate stockholm configuration --- default.nix | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index f14329d4..0900ca7b 100644 --- a/default.nix +++ b/default.nix @@ -6,26 +6,23 @@ let lib = import ; - krebs-modules-path = ./krebs/3modules; - krebs-pkgs-path = ./krebs/5pkgs; - user-modules-path = ./. + "/${current-user-name}/3modules"; - user-pkgs-path = ./. + "/${current-user-name}/5pkgs"; + nspath = ns: p: ./. + "/${ns}/${p}"; + kpath = nspath "krebs"; + upath = nspath current-user-name; - # XXX This is only used interactively, e.g. using get. - pkgs = - let - pkgs = import {}; - args = { - inherit pkgs; - lib = pkgs.lib; - }; - in - pkgs // - import krebs-pkgs-path args // - import user-pkgs-path args; + stockholm = { + imports = map (f: f "3modules") [ kpath upath ]; + + nixpkgs.config.packageOverrides = pkgs: + let + kpkgs = import (kpath "5pkgs") { inherit pkgs; }; + upkgs = import (upath "5pkgs") { pkgs = pkgs // kpkgs; }; + in + kpkgs // upkgs; + }; out = - { inherit pkgs; } // + { inherit (eval {}) pkgs; } // lib.mapAttrs (_: builtins.getAttr "main") (lib.filterAttrs (_: builtins.hasAttr "main") (lib.mapAttrs @@ -43,15 +40,8 @@ let eval = path: import { system = builtins.currentSystem; modules = [ + stockholm path - krebs-modules-path - user-modules-path - ] ++ [ - ({ config, lib, pkgs, ... }@args: { - _module.args.pkgs = - (import krebs-pkgs-path args) // - (import user-pkgs-path args); - }) ]; }; -- cgit v1.2.3 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(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index 0900ca7b..b561cb7d 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 From 41dc859d7ed956addd01579a114549c1984206c5 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 17 Oct 2015 06:30:20 +0200 Subject: allow nix-env -f --- default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index b561cb7d..7223a46e 100644 --- a/default.nix +++ b/default.nix @@ -1,8 +1,10 @@ -{ current-date -, current-host-name -, current-user-name +{ current-date ? abort "current-date not defined" +, current-host-name ? abort "current-host-name not defined" +, current-user-name ? builtins.getEnv "LOGNAME" }: +assert current-user-name != ""; + let lib = import ; -- cgit v1.2.3 From d7367961c3789ab442ae63d2f8b49d8b5204622c Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 17 Oct 2015 06:50:06 +0200 Subject: default out: export config and options --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index 7223a46e..c7365fd5 100644 --- a/default.nix +++ b/default.nix @@ -24,7 +24,7 @@ let }; out = - { inherit (eval {}) pkgs; } // + { inherit (eval {}) config options pkgs; } // lib.mapAttrs (name: _: if builtins.pathExists (./. + "/${name}/default.nix") -- cgit v1.2.3 From aa094e2b81910455e2385c78727da13f03074913 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 17 Oct 2015 07:25:10 +0200 Subject: default out: use nspath in namespace loader --- default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index c7365fd5..fd127084 100644 --- a/default.nix +++ b/default.nix @@ -27,9 +27,9 @@ let { inherit (eval {}) config options pkgs; } // lib.mapAttrs (name: _: - if builtins.pathExists (./. + "/${name}/default.nix") - then import (./. + "/${name}") - else import-1systems (./. + "/${name}/1systems")) + if builtins.pathExists (nspath name "default.nix") + then import (nspath name "default.nix") + else import-1systems (nspath name "1systems")) (lib.filterAttrs (n: t: !lib.hasPrefix "." n && t == "directory") (builtins.readDir ./.)); -- cgit v1.2.3 From d7f0c3d171eec868a8c13bed2e076c65cbfbaabe Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 17 Oct 2015 07:35:21 +0200 Subject: move maybe to krebs lib --- default.nix | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index fd127084..841882f5 100644 --- a/default.nix +++ b/default.nix @@ -7,6 +7,8 @@ assert current-user-name != ""; let lib = import ; + klib = import ./krebs/4lib { inherit lib; }; +in with klib; let nspath = ns: p: ./. + "/${ns}/${p}"; kpath = nspath "krebs"; @@ -67,12 +69,4 @@ let }.${v} or Nothing) (builtins.readDir path))); - # TODO move to lib - Just = x: { type = "maybe"; value = x; }; - Nothing = { type = "maybe"; }; - isMaybe = x: builtins.typeOf x == "set" && x.type or false == "maybe"; - isJust = x: isMaybe x && builtins.hasAttr "value" x; - fromJust = x: assert isJust x; x.value; - catMaybes = xs: map fromJust (builtins.filter isJust xs); - in out -- cgit v1.2.3