From 0d94960783efdcaaee800b22f03c861b8c575d3f Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Mon, 26 Jun 2023 22:02:28 +0800 Subject: [PATCH 1/2] doc: fix defaultText by adding literalExpression I also remove an unnecessary defaultText and fix a typo. --- modules/age-home.nix | 9 +++++---- modules/age.nix | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/modules/age-home.nix b/modules/age-home.nix index c3209ab..9458da9 100644 --- a/modules/age-home.nix +++ b/modules/age-home.nix @@ -149,9 +149,10 @@ with lib; let else "$XDG_RUNTIME_DIR"; in "${baseDir}/${dir}"; - userDirectoryDescription = dir: '' - "$XDG_RUNTIME_DIR"/${dir} on linux or "$(getconf DARWIN_USER_TEMP_DIR)"/${dir} on darwin. - ''; + userDirectoryDescription = dir: + literalExpression '' + "$XDG_RUNTIME_DIR"/${dir} on linux or "$(getconf DARWIN_USER_TEMP_DIR)"/${dir} on darwin. + ''; in { options.age = { package = mkPackageOption pkgs "rage" {}; @@ -170,7 +171,7 @@ in { "${config.home.homeDirectory}/.ssh/id_ed25519" "${config.home.homeDirectory}/.ssh/id_rsa" ]; - defaultText = litteralExpression '' + defaultText = literalExpression '' [ "''${config.home.homeDirectory}/.ssh/id_ed25519" "''${config.home.homeDirectory}/.ssh/id_rsa" diff --git a/modules/age.nix b/modules/age.nix index 8c99214..a5b160c 100644 --- a/modules/age.nix +++ b/modules/age.nix @@ -133,6 +133,7 @@ with lib; let name = mkOption { type = types.str; default = config._module.args.name; + defaultText = literalExpression "config._module.args.name"; description = '' Name of the file used in ''${cfg.secretsDir} ''; @@ -146,6 +147,9 @@ with lib; let path = mkOption { type = types.str; default = "${cfg.secretsDir}/${config.name}"; + defaultText = literalExpression '' + "''${cfg.secretsDir}/''${config.name}" + ''; description = '' Path where the decrypted secret is installed. ''; @@ -167,6 +171,9 @@ with lib; let group = mkOption { type = types.str; default = users.${config.owner}.group or "0"; + defaultText = literalExpression '' + users.''${config.owner}.group or "0" + ''; description = '' Group of the decrypted secret. ''; @@ -183,6 +190,9 @@ in { ageBin = mkOption { type = types.str; default = "${pkgs.rage}/bin/rage"; + defaultText = literalExpression '' + "''${pkgs.rage}/bin/rage" + ''; description = '' The age executable to use. ''; @@ -210,7 +220,6 @@ in { && (builtins.match ".+/" s) == null) # without trailing slash // {description = "${types.str.description} (with check: non-empty without trailing slash)";}; default = "/run/agenix.d"; - defaultText = "/run/agenix.d"; description = '' Where secrets are created before they are symlinked to ''${cfg.secretsDir} ''; @@ -226,6 +235,16 @@ in { "/etc/ssh/ssh_host_rsa_key" ] else []; + defaultText = literalExpression '' + if (config.services.openssh.enable or false) + then map (e: e.path) (lib.filter (e: e.type == "rsa" || e.type == "ed25519") config.services.openssh.hostKeys) + else if isDarwin + then [ + "/etc/ssh/ssh_host_ed25519_key" + "/etc/ssh/ssh_host_rsa_key" + ] + else []; + ''; description = '' Path to SSH keys to be used as identities in age decryption. ''; From 6e8a48c2dca4fd8bd6a002dda1da1645753ef006 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Mon, 26 Jun 2023 23:25:55 +0800 Subject: [PATCH 2/2] doc: fix nixos option format in descriptions --- modules/age.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/age.nix b/modules/age.nix index a5b160c..9468779 100644 --- a/modules/age.nix +++ b/modules/age.nix @@ -135,7 +135,7 @@ with lib; let default = config._module.args.name; defaultText = literalExpression "config._module.args.name"; description = '' - Name of the file used in ''${cfg.secretsDir} + Name of the file used in {option}`age.secretsDir` ''; }; file = mkOption { @@ -221,7 +221,7 @@ in { // {description = "${types.str.description} (with check: non-empty without trailing slash)";}; default = "/run/agenix.d"; description = '' - Where secrets are created before they are symlinked to ''${cfg.secretsDir} + Where secrets are created before they are symlinked to {option}`age.secretsDir` ''; }; identityPaths = mkOption {