From 085a8c2050683ad007e7003f1be5b2e3ade8b4e1 Mon Sep 17 00:00:00 2001 From: DavHau Date: Thu, 3 Apr 2025 17:22:03 +0700 Subject: [PATCH] remove some references to config in options --- clanModules/borgbackup-static/default.nix | 4 ++-- clanModules/static-hosts/default.nix | 6 ++++++ clanModules/syncthing-static-peers/default.nix | 2 +- clanModules/zerotier-static-peers/default.nix | 1 + clanModules/zerotier/shared.nix | 1 + nixosModules/clanCore/backups.nix | 1 + nixosModules/clanCore/facts/compat.nix | 6 +++++- nixosModules/clanCore/facts/default.nix | 5 +++++ nixosModules/clanCore/metadata.nix | 4 ++-- nixosModules/clanCore/state.nix | 3 +++ nixosModules/clanCore/waypipe.nix | 1 + 11 files changed, 28 insertions(+), 6 deletions(-) diff --git a/clanModules/borgbackup-static/default.nix b/clanModules/borgbackup-static/default.nix index a6c529b92..64dae529e 100644 --- a/clanModules/borgbackup-static/default.nix +++ b/clanModules/borgbackup-static/default.nix @@ -9,7 +9,7 @@ in options.clan.borgbackup-static = { excludeMachines = lib.mkOption { type = lib.types.listOf lib.types.str; - example = [ config.clan.core.settings.machine.name ]; + example = lib.literalExpression "[ config.clan.core.settings.machine.name ]"; default = [ ]; description = '' Machines that should not be backuped. @@ -20,7 +20,7 @@ in }; includeMachines = lib.mkOption { type = lib.types.listOf lib.types.str; - example = [ config.clan.core.settings.machine.name ]; + example = lib.literalExpression "[ config.clan.core.settings.machine.name ]"; default = [ ]; description = '' Machines that should be backuped. diff --git a/clanModules/static-hosts/default.nix b/clanModules/static-hosts/default.nix index 2e2f25ccc..951d4fd54 100644 --- a/clanModules/static-hosts/default.nix +++ b/clanModules/static-hosts/default.nix @@ -8,6 +8,12 @@ [ ] else [ config.clan.core.settings.machine.name ]; + defaultText = lib.literalExpression '' + if config.clan.static-hosts.topLevelDomain != "" then + [ ] + else + [ config.clan.core.settings.machine.name ]; + ''; description = "Hosts that should be excluded"; }; topLevelDomain = lib.mkOption { diff --git a/clanModules/syncthing-static-peers/default.nix b/clanModules/syncthing-static-peers/default.nix index bdb539bde..2b10e0237 100644 --- a/clanModules/syncthing-static-peers/default.nix +++ b/clanModules/syncthing-static-peers/default.nix @@ -48,7 +48,7 @@ in options.clan.syncthing-static-peers = { excludeMachines = lib.mkOption { type = lib.types.listOf lib.types.str; - example = [ config.clan.core.settings.machine.name ]; + example = lib.literalExpression "[ config.clan.core.settings.machine.name ]"; default = [ ]; description = '' Machines that should not be added. diff --git a/clanModules/zerotier-static-peers/default.nix b/clanModules/zerotier-static-peers/default.nix index 96abe878f..d9105dcf9 100644 --- a/clanModules/zerotier-static-peers/default.nix +++ b/clanModules/zerotier-static-peers/default.nix @@ -28,6 +28,7 @@ in excludeHosts = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ config.clan.core.settings.machine.name ]; + defaultText = lib.literalExpression "[ config.clan.core.settings.machine.name ]"; description = "Hosts that should be excluded"; }; networkIps = lib.mkOption { diff --git a/clanModules/zerotier/shared.nix b/clanModules/zerotier/shared.nix index b1eb9f709..2556222ee 100644 --- a/clanModules/zerotier/shared.nix +++ b/clanModules/zerotier/shared.nix @@ -35,6 +35,7 @@ in excludeHosts = lib.mkOption { type = listOf str; default = [ config.clan.core.settings.machine.name ]; + defaultText = lib.literalExpression "[ config.clan.core.settings.machine.name ]"; description = "Hosts that should be excluded"; }; networkIps = lib.mkOption { diff --git a/nixosModules/clanCore/backups.nix b/nixosModules/clanCore/backups.nix index 42cff1068..e8a3d7393 100644 --- a/nixosModules/clanCore/backups.nix +++ b/nixosModules/clanCore/backups.nix @@ -11,6 +11,7 @@ name = lib.mkOption { type = lib.types.str; default = name; + defaultText = "attribute name of the backup provider"; description = '' Name of the backup provider ''; diff --git a/nixosModules/clanCore/facts/compat.nix b/nixosModules/clanCore/facts/compat.nix index 8fc81b233..4cd864ec1 100644 --- a/nixosModules/clanCore/facts/compat.nix +++ b/nixosModules/clanCore/facts/compat.nix @@ -47,6 +47,7 @@ name = lib.mkOption { type = lib.types.str; default = service.config._module.args.name; + defaultText = "attribute name of the service"; description = '' Namespace of the service ''; @@ -97,6 +98,7 @@ name of the secret ''; default = secret.config._module.args.name; + defaultText = "attribute name of the secret"; }; path = lib.mkOption { type = lib.types.path; @@ -111,6 +113,7 @@ groups = lib.mkOption { type = lib.types.listOf lib.types.str; default = config.clan.core.sops.defaultGroups; + defaultText = lib.literalExpression "config.clan.core.sops.defaultGroups"; description = '' Groups to decrypt the secret for. By default we always use the user's key. ''; @@ -133,6 +136,7 @@ name of the fact ''; default = fact.config._module.args.name; + defaultText = "attribute name of the fact"; }; path = lib.mkOption { type = lib.types.path; @@ -145,10 +149,10 @@ defaultText = lib.literalExpression "\${config.clan.core.settings.directory}/machines/\${config.clan.core.settings.machine.name}/facts/\${fact.config._module.args.name}"; }; value = lib.mkOption { - defaultText = lib.literalExpression "\${config.clan.core.settings.directory}/\${fact.config.path}"; type = lib.types.nullOr lib.types.str; default = if builtins.pathExists fact.config.path then lib.strings.fileContents fact.config.path else null; + defaultText = "null if fact.config.path does not exist, else the content of the file"; }; }; }) diff --git a/nixosModules/clanCore/facts/default.nix b/nixosModules/clanCore/facts/default.nix index 7f8c6781b..98215c927 100644 --- a/nixosModules/clanCore/facts/default.nix +++ b/nixosModules/clanCore/facts/default.nix @@ -87,6 +87,7 @@ name = lib.mkOption { type = lib.types.str; default = service.config._module.args.name; + defaultText = "attribute name of the service"; description = '' Namespace of the service ''; @@ -178,6 +179,7 @@ name of the secret ''; default = secret.config._module.args.name; + defaultText = "attribute name of the secret"; }; path = lib.mkOption { type = lib.types.str; @@ -185,12 +187,14 @@ path to a secret which is generated by the generator ''; default = config.clan.core.facts.secretPathFunction secret; + defaultText = lib.literalExpression "config.clan.core.facts.secretPathFunction secret"; }; } // lib.optionalAttrs (config.clan.core.facts.secretModule == "clan_cli.facts.secret_modules.sops") { groups = lib.mkOption { type = lib.types.listOf lib.types.str; default = config.clan.core.sops.defaultGroups; + defaultText = lib.literalExpression "config.clan.core.sops.defaultGroups"; description = '' Groups to decrypt the secret for. By default we always use the user's key. ''; @@ -213,6 +217,7 @@ name of the public fact ''; default = fact.config._module.args.name; + defaultText = "attribute name of the public fact"; }; path = lib.mkOption { type = lib.types.path; diff --git a/nixosModules/clanCore/metadata.nix b/nixosModules/clanCore/metadata.nix index f0278a6ee..644d16120 100644 --- a/nixosModules/clanCore/metadata.nix +++ b/nixosModules/clanCore/metadata.nix @@ -95,7 +95,7 @@ in description = '' the name of the clan ''; - # Set by the flake, so it's read-only in the maschine + # Set by the flake, so it's read-only in the machine readOnly = true; }; icon = lib.mkOption { @@ -103,7 +103,7 @@ in description = '' the location of the clan icon ''; - # Set by the flake, so it's read-only in the maschine + # Set by the flake, so it's read-only in the machine readOnly = true; }; machine = mkOption { diff --git a/nixosModules/clanCore/state.nix b/nixosModules/clanCore/state.nix index 5e0425092..5c2877b6b 100644 --- a/nixosModules/clanCore/state.nix +++ b/nixosModules/clanCore/state.nix @@ -19,6 +19,7 @@ name = lib.mkOption { type = lib.types.strMatching "^[a-zA-Z0-9_-]+$"; default = name; + defaultText = "attribute name of the state"; description = '' Name of the state ''; @@ -43,6 +44,7 @@ preBackupCommand = lib.mkOption { type = lib.types.nullOr lib.types.str; default = if config.preBackupScript == null then null else "pre-backup-${name}"; + defaultText = lib.literalExpression ''null if preBackupScript set, or else "pre-backup-${name}"''; readOnly = true; description = '' Use this command in backup providers. It contains the content of preBackupScript. @@ -73,6 +75,7 @@ preRestoreCommand = lib.mkOption { type = lib.types.nullOr lib.types.str; default = if config.preRestoreScript == null then null else "pre-restore-${name}"; + defaultText = lib.literalExpression ''null if preRestoreScript set, or else "pre-restore-${name}"''; readOnly = true; description = '' This command can be called to restore the state dir from a backup. diff --git a/nixosModules/clanCore/waypipe.nix b/nixosModules/clanCore/waypipe.nix index 37920ae2d..cfe9740c9 100644 --- a/nixosModules/clanCore/waypipe.nix +++ b/nixosModules/clanCore/waypipe.nix @@ -25,6 +25,7 @@ command = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ (lib.getExe pkgs.foot) ]; + defaultText = "executable of pkgs.foot"; description = "Commands that waypipe should run"; }; };