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

View File

@ -67,16 +67,7 @@ let
secretsSetupMethod = mkOption { secretsSetupMethod = mkOption {
type = types.str; type = types.str;
default = throw '' default = null;
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
'';
}; };
generateSecretsScript = mkOption { generateSecretsScript = mkOption {
@ -141,6 +132,21 @@ in {
inherit options; inherit options;
config = { 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. # This target is active when secrets have been setup successfully.
systemd.targets.nix-bitcoin-secrets = mkIf (cfg.secretsSetupMethod != "manual") { systemd.targets.nix-bitcoin-secrets = mkIf (cfg.secretsSetupMethod != "manual") {
# This ensures that the secrets target is always activated when switching # This ensures that the secrets target is always activated when switching