summaryrefslogtreecommitdiffstats
path: root/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix32
1 files changed, 21 insertions, 11 deletions
diff --git a/default.nix b/default.nix
index 1637aa464..278f1d14d 100644
--- a/default.nix
+++ b/default.nix
@@ -1,6 +1,15 @@
-{ current-date ? abort "current-date not defined"
-, current-host-name ? abort "current-host-name not defined"
-, current-user-name ? builtins.getEnv "LOGNAME"
+{ configuration ? import (nixpkgs-path + "/nixos/lib/from-env.nix") "NIXOS_CONFIG" <nixos-config>
+, system ? builtins.currentSystem
+, current-host-name ?
+ 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"
+, nixpkgs-path ?
+ if (builtins.tryEval <nixpkgs/krebs>).success
+ then <upstream-nixpkgs>
+ else <nixpkgs>
, StrictHostKeyChecking ? "yes"
}@args:
@@ -8,26 +17,26 @@ let stockholm = {
inherit krebs;
inherit users;
inherit lib;
- inherit pkgs;
+ inherit config options pkgs;
+ system = config.system.build.toplevel;
};
krebs = import ./krebs (args // { inherit lib stockholm; });
lib = let
- nlib = import <nixpkgs/lib>;
+ nlib = import (slib.npath "lib");
klib = import (slib.kpath "4lib") { lib = nlib; };
slib = rec {
- stockholm-path = ./.;
- nspath = ns: p: stockholm-path + "/${ns}/${p}";
- kpath = nspath "krebs";
- upath = nspath current-user-name;
+ npath = p: nixpkgs-path + "/${p}";
+ kpath = p: ./. + "/krebs/${p}";
+ upath = p: ./. + "/${current-user-name}/${p}";
};
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;
- inherit (eval {}) pkgs;
+ inherit (eval configuration) config options pkgs;
base-module = { config, ... }: {
imports = builtins.filter lib.dir.has-default-nix (lib.concatLists [
@@ -45,7 +54,8 @@ let stockholm = {
in kpkgs // upkgs;
};
- eval = config: import <nixpkgs/nixos/lib/eval-config.nix> {
+ eval = config: import (lib.npath "nixos/lib/eval-config.nix") {
+ inherit system;
specialArgs = {
inherit lib;
};