1
0
Fork 0

Properly set temp hostName and secretPath for configuration.nix.

This commit is contained in:
Kevin Baensch 2020-04-01 09:52:39 +02:00
parent c543303ab9
commit 1476ff6acb
Signed by: derped
GPG Key ID: C0F1D326C7626543
1 changed files with 11 additions and 6 deletions

View File

@ -5,12 +5,17 @@ with lib;
let
fn = import ./fn.nix { inherit lib; };
# hostName can be set with -I hostName=$HOSTNAME, defaults to the contents of /secret/hostName
hostName = let
hostVal = (tryEval <hostName>).value;
in fn.ifelse (hostVal != false)
hostVal
(fileContents /secret/hostName);
# 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
secretPath = fn.ifelse ((tryEval <secretPath>).value != false)
<secretPath>
/secret;
hostName = (findFirst
(elem: elem.prefix == "hostName")
{ path = (fileContents "${secretPath}/hostName"); }
nixPath
).path;
machinePath = (builtins.toPath ( ./machines + ("/" + hostName)));
machineFiles = fn.lst { p = machinePath; b = true; };
configFiles = fn.lst { p = (toString ./config); b = true; };