Simplify $NIX_PATH evaluation.
This commit is contained in:
parent
7c1f7aa9a1
commit
081d10bc21
2 changed files with 9 additions and 2 deletions
|
@ -1,10 +1,16 @@
|
||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
|
|
||||||
|
with builtins;
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
fn = import ./fn.nix { inherit lib; };
|
||||||
# hostName can be set with -I hostName=$HOSTNAME, defaults to the contents of /secret/hostName
|
# hostName can be set with -I hostName=$HOSTNAME, defaults to the contents of /secret/hostName
|
||||||
hostName = (findFirst (elem: elem.prefix == "hostName") { path = (fileContents /secret/hostName); } builtins.nixPath).path;
|
hostName = let
|
||||||
|
hostVal = (tryEval <hostName>).value;
|
||||||
|
in fn.ifelse (hostVal != false)
|
||||||
|
hostVal
|
||||||
|
(fileContents /secret/hostName);
|
||||||
machinePath = (builtins.toPath ( ./machines + ("/" + hostName)));
|
machinePath = (builtins.toPath ( ./machines + ("/" + hostName)));
|
||||||
machineConf = machinePath + "/configuration.nix";
|
machineConf = machinePath + "/configuration.nix";
|
||||||
machineOpts = machinePath + "/options.nix";
|
machineOpts = machinePath + "/options.nix";
|
||||||
|
|
|
@ -68,7 +68,8 @@ in {
|
||||||
};
|
};
|
||||||
secretPath = mkOption {
|
secretPath = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = (findFirst (elem: elem.prefix == "secretPath") { path = "/secret"; } builtins.nixPath).path;
|
default = let sPathVal = (tryEval <secretPath>).value;
|
||||||
|
in fn.ifelse (sPathVal != false) sPathVal "/secret";
|
||||||
description = ''
|
description = ''
|
||||||
Path to you systems secret folder containing files with sensitive information.
|
Path to you systems secret folder containing files with sensitive information.
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in a new issue