docs/options: Add option reference generator

Evaluate custom module options through a synthetic system, stabilize
configuration-dependent defaults for rendering, and commit the generated
reference beside its updater.
This commit is contained in:
2026-08-01 23:59:17 +01:00
parent 4084dfe64e
commit b44095f1ed
7 changed files with 472 additions and 9 deletions
+19 -4
View File
@@ -3,7 +3,7 @@ let
inherit (builtins) substring match;
inherit (lib)
nameValuePair optional optionalString optionalAttrs mapAttrs' mapAttrsToList concatStringsSep
concatMapStringsSep mkIf;
concatMapStringsSep mkIf mkOption literalExpression;
inherit (lib.my) mkOpt' mkBoolOpt';
jobType = with lib.types; submodule ({ name, ... }@args:
@@ -15,12 +15,22 @@ let
repo = mkOpt' str null "borg repository URL";
passFile = mkOpt' (nullOr str) null "Path to file containing passphrase";
archivePrefix = mkOpt' str "${config.networking.hostName}-${name}-" "Prefix to start new archives with";
archivePrefix = mkOption {
type = str;
default = "${config.networking.hostName}-${name}-";
defaultText = literalExpression ''"''${config.networking.hostName}-''${name}-"'';
description = "Prefix to start new archives with";
};
dateFormat = mkOpt' str "+%Y-%m-%dT%H:%M:%S" "Format passed to the date command";
compression = mkOpt' str "zstd,3" "Compression options";
lvs = mkOpt' (listOf str) null "Thin LVs to backup (vg/lv format)";
prune = {
pattern = mkOpt' str "sh:${cfg.archivePrefix}*" "Borg pattern to select archives for pruning";
pattern = mkOption {
type = str;
default = "sh:${cfg.archivePrefix}*";
defaultText = literalExpression ''"sh:''${config.archivePrefix}*"'';
description = "Borg pattern to select archives for pruning";
};
keep = mkOpt' (attrsOf (either int str)) { } "Borg pruning params";
};
@@ -129,7 +139,12 @@ in
thinToolsPackage = mkOpt' package pkgs.thin-provisioning-tools "Package containing thin-provisioning-tools";
# Really we should use the version from the overlay, but the package is quite far behind...
# Not bothering to update until Borg 2.0 releases
package = mkOpt' package inputs.borgthin.packages.${config.nixpkgs.system}.borgthin "borgthin package";
package = mkOption {
type = package;
default = inputs.borgthin.packages.${config.nixpkgs.system}.borgthin;
defaultText = literalExpression "inputs.borgthin.packages.\${system}.borgthin";
description = "borgthin package";
};
jobs = mkOpt' (attrsOf jobType) { } "borgthin jobs";
};
+3
View File
@@ -190,6 +190,9 @@ let
type = unspecified;
default = ext;
visible = "shallow";
# Build-target plumbing: the default evaluates a whole alternate system, so keep
# it out of the generated option docs (see `optionsDoc` in flake.nix).
internal = true;
description = "Configuration as ${desc}.";
};
in
+7 -2
View File
@@ -1,6 +1,6 @@
{ lib, pkgs, config, ... }:
let
inherit (lib) mkMerge mkIf mkForce genAttrs concatMapStringsSep;
inherit (lib) mkMerge mkIf mkForce genAttrs concatMapStringsSep mkOption literalExpression;
inherit (lib.my) mkOpt' mkBoolOpt';
cfg = config.my.netboot;
@@ -47,7 +47,12 @@ in
server = {
enable = mkBoolOpt' false "Whether a netboot server should be enabled.";
ip = mkOpt' str null "IP clients should connect to via TFTP.";
host = mkOpt' str config.networking.fqdn "Hostname clients should connect to over HTTP / NFS.";
host = mkOption {
type = str;
default = config.networking.fqdn;
defaultText = literalExpression "config.networking.fqdn";
description = "Hostname clients should connect to over HTTP / NFS.";
};
allowedPrefixes = mkOpt' (listOf str) null "Prefixes clients should be allowed to connect from (NFS).";
installer = {
storeSize = mkOpt' str "16GiB" "Total allowed writable size of store.";