summaryrefslogtreecommitdiffstats
path: root/default.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2015-10-17 11:18:55 +0200
committermakefu <github@syntax-fehler.de>2015-10-17 11:18:55 +0200
commit2454867a529ab44f22c9e1c51e3642ac4c391bad (patch)
treeaa0aa4d81cd95046cce98ff770642f6c21fb31b2 /default.nix
parentf83b3770dd401004bef0233c3de0eb07686788a5 (diff)
parent4d32e1575705e544c8cbb5834447d71c1b577970 (diff)
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix84
1 files changed, 31 insertions, 53 deletions
diff --git a/default.nix b/default.nix
index f14329d40..841882f54 100644
--- a/default.nix
+++ b/default.nix
@@ -1,61 +1,49 @@
-{ 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 <nixpkgs/lib>;
+ klib = import ./krebs/4lib { inherit lib; };
+in with klib; let
+
+ nspath = ns: p: ./. + "/${ns}/${p}";
+ kpath = nspath "krebs";
+ upath = nspath current-user-name;
- krebs-modules-path = ./krebs/3modules;
- krebs-pkgs-path = ./krebs/5pkgs;
- user-modules-path = ./. + "/${current-user-name}/3modules";
- user-pkgs-path = ./. + "/${current-user-name}/5pkgs";
+ stockholm = {
+ imports = map (f: f "3modules") [ kpath upath ];
- # XXX This is only used interactively, e.g. using get.
- pkgs =
- let
- pkgs = import <nixpkgs> {};
- args = {
- inherit pkgs;
- lib = pkgs.lib;
- };
- in
- pkgs //
- import krebs-pkgs-path args //
- import user-pkgs-path args;
+ nixpkgs.config.packageOverrides = pkgs:
+ let
+ kpkgs = import (kpath "5pkgs") { inherit pkgs; };
+ upkgs = import (upath "5pkgs") { pkgs = pkgs // kpkgs; };
+ in
+ kpkgs // upkgs;
+ };
out =
- { inherit 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 ./.)));
+ { inherit (eval {}) config options pkgs; } //
+ lib.mapAttrs
+ (name: _:
+ 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 ./.));
eval = path: import <nixpkgs/nixos/lib/eval-config.nix> {
- 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);
- })
];
};
- 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;
@@ -63,8 +51,6 @@ let
fetch = import ./krebs/0tools/fetch.nix { inherit config lib; };
};
- mapNixDir = f: path: lib.mapAttrs (_: f) (nixDir path);
-
nixDir = path:
builtins.listToAttrs
(catMaybes
@@ -83,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