vars: add .exists to files
This commit is contained in:
@@ -304,6 +304,15 @@ in
|
|||||||
description = "The unix file mode of the file. Must be a 4-digit octal number.";
|
description = "The unix file mode of the file. Must be a 4-digit octal number.";
|
||||||
default = "0400";
|
default = "0400";
|
||||||
};
|
};
|
||||||
|
exists = mkOption {
|
||||||
|
description = ''
|
||||||
|
Returns true if the file exists, This is used to guard against reading not set value in evaluation.
|
||||||
|
This currently only works for non secret files.
|
||||||
|
'';
|
||||||
|
type = bool;
|
||||||
|
default = if file.config.secret then throw "Cannot determine existance of secret file" else false;
|
||||||
|
defaultText = "Throws error because the existance of a secret file cannot be determined";
|
||||||
|
};
|
||||||
value =
|
value =
|
||||||
mkOption {
|
mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ in
|
|||||||
);
|
);
|
||||||
value = mkIf (file.config.secret == false) (
|
value = mkIf (file.config.secret == false) (
|
||||||
# dynamically adjust priority to allow overriding with mkDefault in case the file is not found
|
# dynamically adjust priority to allow overriding with mkDefault in case the file is not found
|
||||||
if (pathExists file.config.flakePath) then
|
if file.config.exists then
|
||||||
# if the file is found it should have normal priority
|
# if the file is found it should have normal priority
|
||||||
readFile file.config.flakePath
|
readFile file.config.flakePath
|
||||||
else
|
else
|
||||||
@@ -34,6 +34,7 @@ in
|
|||||||
throw "Please run `clan vars generate ${config.clan.core.settings.machine.name}` as file was not found: ${file.config.path}"
|
throw "Please run `clan vars generate ${config.clan.core.settings.machine.name}` as file was not found: ${file.config.path}"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
exists = mkIf (file.config.secret == false) (pathExists file.config.flakePath);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user