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 let
fn = import ./fn.nix { inherit lib; }; fn = import ./fn.nix { inherit lib; };
# hostName can be set with -I hostName=$HOSTNAME, defaults to the contents of /secret/hostName # Cannot use <hostName> here as those evaluations only work with existing paths >.<
hostName = let # hostName and secretPtah can be set with -I hostName=$HOSTNAME and -I secretPath=$SECRETPATH respectively
hostVal = (tryEval <hostName>).value; # , defaults to the contents of /secret/hostName
in fn.ifelse (hostVal != false) secretPath = fn.ifelse ((tryEval <secretPath>).value != false)
hostVal <secretPath>
(fileContents /secret/hostName); /secret;
hostName = (findFirst
(elem: elem.prefix == "hostName")
{ path = (fileContents "${secretPath}/hostName"); }
nixPath
).path;
machinePath = (builtins.toPath ( ./machines + ("/" + hostName))); machinePath = (builtins.toPath ( ./machines + ("/" + hostName)));
machineFiles = fn.lst { p = machinePath; b = true; }; machineFiles = fn.lst { p = machinePath; b = true; };
configFiles = fn.lst { p = (toString ./config); b = true; }; configFiles = fn.lst { p = (toString ./config); b = true; };