2023-09-11 20:23:04 +02:00
|
|
|
{lib, ...}:
|
2020-03-28 20:03:48 +01:00
|
|
|
with builtins;
|
2023-09-11 20:23:04 +02:00
|
|
|
with lib; let
|
|
|
|
fn = import (toString ./fn.nix) {inherit lib;};
|
2020-04-01 09:52:39 +02:00
|
|
|
# Cannot use <hostName> here as those evaluations only work with existing paths >.<
|
|
|
|
# hostName and secretPtah can be set with -I hostName=$HOSTNAME and -I secretPath=$SECRETPATH respectively
|
|
|
|
# , defaults to the contents of /secret/hostName
|
2023-09-11 20:23:04 +02:00
|
|
|
secretPath =
|
|
|
|
fn.ifelse ((tryEval (toString <secretPath>)).value != false)
|
2020-05-10 17:16:08 +02:00
|
|
|
(toString <secretPath>)
|
|
|
|
(toString /secret);
|
2023-09-11 20:23:04 +02:00
|
|
|
hostName =
|
|
|
|
(
|
|
|
|
findFirst
|
2020-05-10 17:16:08 +02:00
|
|
|
(elem: elem.prefix == "hostName")
|
2023-09-11 20:23:04 +02:00
|
|
|
{path = fileContents "${secretPath}/hostName";}
|
2020-05-10 17:16:08 +02:00
|
|
|
nixPath
|
2023-09-11 20:23:04 +02:00
|
|
|
)
|
|
|
|
.path;
|
|
|
|
machinePath = builtins.toPath (./machines + ("/" + hostName));
|
|
|
|
machineFiles = fn.lst {
|
|
|
|
p = machinePath;
|
|
|
|
b = true;
|
|
|
|
};
|
|
|
|
configFiles = fn.lst {
|
|
|
|
p = toString ./config;
|
|
|
|
b = true;
|
|
|
|
};
|
|
|
|
pkgsFiles = fn.lst {
|
|
|
|
p = toString ./pkgs;
|
|
|
|
b = true;
|
|
|
|
};
|
|
|
|
serviceFiles = fn.lst {
|
|
|
|
p = toString ./services;
|
|
|
|
b = true;
|
|
|
|
};
|
2019-03-23 02:50:48 +01:00
|
|
|
in {
|
2023-09-11 20:23:04 +02:00
|
|
|
imports =
|
|
|
|
[
|
|
|
|
./options/machine.nix
|
|
|
|
./services/mailserver/default.nix
|
|
|
|
]
|
|
|
|
++ machineFiles
|
|
|
|
++ configFiles
|
|
|
|
++ pkgsFiles
|
|
|
|
++ serviceFiles;
|
2019-02-26 13:44:40 +01:00
|
|
|
}
|