From 349f904e79544c9d80a40f7552beaa3bebb29434 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Wed, 8 Dec 2021 04:07:25 +0100 Subject: [PATCH] secrets: use assertion instead of error in default value This enables generating module option documentation. --- modules/secrets/secrets.nix | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/modules/secrets/secrets.nix b/modules/secrets/secrets.nix index 4776bca..4ad7752 100644 --- a/modules/secrets/secrets.nix +++ b/modules/secrets/secrets.nix @@ -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