secrets: use assertion instead of error in default value

This enables generating module option documentation.
This commit is contained in:
Erik Arvstedt 2021-12-08 04:07:25 +01:00
parent 1b3d3620fb
commit 349f904e79
No known key found for this signature in database
GPG Key ID: 33312B944DD97846
1 changed files with 16 additions and 10 deletions

View File

@ -67,16 +67,7 @@ let
secretsSetupMethod = mkOption {
type = types.str;
default = throw ''
Error: No secrets setup method has been defined.
To fix this, choose one of the following:
- Use one of the deployment methods in ${toString ./../deployment}
- Set `nix-bitcoin.generateSecrets = true` to automatically generate secrets
- Set `nix-bitcoin.secretsSetupMethod = "manual"` if you want to manually setup secrets
'';
default = null;
};
generateSecretsScript = mkOption {
@ -141,6 +132,21 @@ in {
inherit options;
config = {
assertions = [
{ assertion = cfg.secretsSetupMethod != null;
message = ''
No secrets setup method has been defined.
To fix this, choose one of the following:
- Use one of the deployment methods in ${toString ./../deployment}
- Set `nix-bitcoin.generateSecrets = true` to automatically generate secrets
- Set `nix-bitcoin.secretsSetupMethod = "manual"` if you want to manually setup secrets
'';
}
];
# This target is active when secrets have been setup successfully.
systemd.targets.nix-bitcoin-secrets = mkIf (cfg.secretsSetupMethod != "manual") {
# This ensures that the secrets target is always activated when switching