2016-02-04 04:40:26 +00:00
|
|
|
{ configuration ? import (nixpkgs-path + "/nixos/lib/from-env.nix") "NIXOS_CONFIG" <nixos-config>
|
|
|
|
, system ? builtins.currentSystem
|
|
|
|
, current-host-name ?
|
2016-02-04 03:47:58 +00:00
|
|
|
let v = builtins.getEnv "HOSTNAME"; in
|
|
|
|
if v != "" then v else builtins.readFile /proc/sys/kernel/hostname
|
|
|
|
, current-user-name ?
|
|
|
|
let v = builtins.getEnv "LOGNAME"; in
|
|
|
|
if v != "" then v else abort "undefined variable: LOGNAME"
|
2016-02-04 04:40:26 +00:00
|
|
|
, nixpkgs-path ?
|
|
|
|
if (builtins.tryEval <nixpkgs/krebs>).success
|
|
|
|
then <upstream-nixpkgs>
|
|
|
|
else <nixpkgs>
|
2015-10-21 22:20:16 +00:00
|
|
|
, StrictHostKeyChecking ? "yes"
|
|
|
|
}@args:
|
2015-07-24 15:34:08 +00:00
|
|
|
|
2015-10-20 01:56:38 +00:00
|
|
|
let stockholm = {
|
2015-10-20 00:33:58 +00:00
|
|
|
inherit krebs;
|
|
|
|
inherit users;
|
|
|
|
inherit lib;
|
2016-02-04 04:40:26 +00:00
|
|
|
inherit config options pkgs;
|
|
|
|
system = config.system.build.toplevel;
|
2015-10-20 00:33:58 +00:00
|
|
|
};
|
|
|
|
|
2015-10-21 22:20:16 +00:00
|
|
|
krebs = import ./krebs (args // { inherit lib stockholm; });
|
2015-10-20 22:08:18 +00:00
|
|
|
|
2015-11-09 18:49:18 +00:00
|
|
|
lib = let
|
2016-02-04 03:35:39 +00:00
|
|
|
nlib = import (slib.npath "lib");
|
2015-11-09 18:49:18 +00:00
|
|
|
klib = import (slib.kpath "4lib") { lib = nlib; };
|
|
|
|
slib = rec {
|
2016-02-04 06:12:56 +00:00
|
|
|
nspath = ns: p: ./. + "/${ns}/${p}";
|
2016-02-04 04:40:26 +00:00
|
|
|
npath = p: nixpkgs-path + "/${p}";
|
2016-02-04 06:12:56 +00:00
|
|
|
kpath = nspath "krebs";
|
|
|
|
upath = nspath current-user-name;
|
2015-10-20 22:08:18 +00:00
|
|
|
};
|
2015-11-09 18:49:18 +00:00
|
|
|
ulib = let p = slib.upath "4lib"; in
|
|
|
|
nlib.optionalAttrs (klib.dir.has-default-nix p)
|
|
|
|
(import p { lib = nlib // klib; });
|
|
|
|
in nlib // klib // slib // ulib // builtins;
|
2015-10-17 03:44:42 +00:00
|
|
|
|
2016-02-04 04:40:26 +00:00
|
|
|
inherit (eval configuration) config options pkgs;
|
2015-10-21 20:29:35 +00:00
|
|
|
|
2015-10-25 13:15:21 +00:00
|
|
|
base-module = { config, ... }: {
|
2015-11-09 01:58:21 +00:00
|
|
|
imports = builtins.filter lib.dir.has-default-nix (lib.concatLists [
|
2015-11-09 18:49:18 +00:00
|
|
|
(map (f: f "2configs") [ lib.upath ])
|
|
|
|
(map (f: f "3modules") [ lib.kpath lib.upath ])
|
2016-02-11 02:47:26 +00:00
|
|
|
(map (f: f "5pkgs") [ lib.kpath lib.upath ])
|
2015-11-06 21:05:36 +00:00
|
|
|
]);
|
2015-10-17 03:44:42 +00:00
|
|
|
|
2015-10-25 13:15:21 +00:00
|
|
|
krebs.current.enable = true;
|
|
|
|
krebs.current.host = config.krebs.hosts.${current-host-name};
|
|
|
|
krebs.current.user = config.krebs.users.${current-user-name};
|
2015-10-17 03:44:42 +00:00
|
|
|
};
|
2015-10-02 13:29:47 +00:00
|
|
|
|
2016-02-04 03:35:39 +00:00
|
|
|
eval = config: import (lib.npath "nixos/lib/eval-config.nix") {
|
2016-02-04 04:40:26 +00:00
|
|
|
inherit system;
|
2015-10-20 22:08:18 +00:00
|
|
|
specialArgs = {
|
|
|
|
inherit lib;
|
|
|
|
};
|
2015-09-26 22:22:50 +00:00
|
|
|
modules = [
|
2015-10-20 01:49:10 +00:00
|
|
|
base-module
|
2015-10-20 00:33:58 +00:00
|
|
|
config
|
2015-07-25 16:16:51 +00:00
|
|
|
];
|
|
|
|
};
|
2015-07-24 15:34:08 +00:00
|
|
|
|
2015-10-20 00:33:58 +00:00
|
|
|
# TODO move user namespaces' to users/, so no exception for krebs/ is needed
|
|
|
|
users =
|
|
|
|
lib.mapAttrs
|
|
|
|
(name: _: eval-all-systems (lib.nspath name "1systems"))
|
|
|
|
(lib.filterAttrs
|
|
|
|
(n: t: !lib.hasPrefix "." n && t == "directory" && n != "krebs")
|
|
|
|
(builtins.readDir ./.));
|
|
|
|
|
|
|
|
eval-all-systems = path:
|
|
|
|
lib.mapAttrs'
|
|
|
|
(n: _: (lib.nameValuePair (lib.removeSuffix ".nix" n)
|
|
|
|
(eval-system (path + "/${n}"))))
|
|
|
|
(builtins.readDir path);
|
2015-09-26 22:22:50 +00:00
|
|
|
|
2015-10-20 00:33:58 +00:00
|
|
|
eval-system = path: rec {
|
2015-09-26 22:22:50 +00:00
|
|
|
inherit (eval path) config options;
|
|
|
|
system = config.system.build.toplevel;
|
|
|
|
};
|
|
|
|
|
2015-10-20 01:56:38 +00:00
|
|
|
in stockholm
|