1
0
forked from clan/clan-core

reference docs: add missing description fields and enforce it from now on

This commit is contained in:
DavHau 2024-07-04 13:32:57 +07:00
parent 0a4abd0e46
commit 208021ee1c
6 changed files with 37 additions and 14 deletions

View File

@ -91,6 +91,7 @@ in
options.clan.postgresql = { options.clan.postgresql = {
# we are reimplemeting ensureDatabase and ensureUser options here to allow to create databases with options # we are reimplemeting ensureDatabase and ensureUser options here to allow to create databases with options
databases = lib.mkOption { databases = lib.mkOption {
description = "Databases to create";
default = { }; default = { };
type = lib.types.attrsOf ( type = lib.types.attrsOf (
lib.types.submodule ( lib.types.submodule (
@ -114,6 +115,7 @@ in
description = "Create the database if it does not exist."; description = "Create the database if it does not exist.";
}; };
create.options = lib.mkOption { create.options = lib.mkOption {
description = "Options to pass to the CREATE DATABASE command.";
type = lib.types.lazyAttrsOf lib.types.str; type = lib.types.lazyAttrsOf lib.types.str;
default = { }; default = { };
example = { example = {
@ -135,12 +137,14 @@ in
); );
}; };
users = lib.mkOption { users = lib.mkOption {
description = "Users to create";
default = { }; default = { };
type = lib.types.attrsOf ( type = lib.types.attrsOf (
lib.types.submodule ( lib.types.submodule (
{ name, ... }: { name, ... }:
{ {
options.name = lib.mkOption { options.name = lib.mkOption {
description = "User name";
type = lib.types.str; type = lib.types.str;
default = name; default = name;
}; };

View File

@ -7,6 +7,10 @@
{ {
options.clan.syncthing = { options.clan.syncthing = {
id = lib.mkOption { id = lib.mkOption {
description = ''
The ID of the machine.
It is generated automatically by default.
'';
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
example = "BABNJY4-G2ICDLF-QQEG7DD-N3OBNGF-BCCOFK6-MV3K7QJ-2WUZHXS-7DTW4AS"; example = "BABNJY4-G2ICDLF-QQEG7DD-N3OBNGF-BCCOFK6-MV3K7QJ-2WUZHXS-7DTW4AS";
default = config.clan.core.facts.services.syncthing.public."syncthing.pub".value or null; default = config.clan.core.facts.services.syncthing.public."syncthing.pub".value or null;

View File

@ -30,7 +30,7 @@ let
options: options:
pkgs.nixosOptionsDoc { pkgs.nixosOptionsDoc {
options = options; options = options;
warningsAreErrors = false; warningsAreErrors = true;
}; };
# clanModules docs # clanModules docs

View File

@ -67,9 +67,19 @@
publicDirectory = lib.mkOption { publicDirectory = lib.mkOption {
type = lib.types.nullOr lib.types.path; type = lib.types.nullOr lib.types.path;
default = null; default = null;
description = ''
The directory where public facts are stored.
'';
}; };
services = lib.mkOption { services = lib.mkOption {
description = ''
Services to generate secrets and facts for.
Each service can have a generator script which generates the secrets and facts.
The generator script is expected to generate all secrets and facts defined for this service.
A `service` does not need to ba analogous to a systemd service, it can be any group of facts and secrets that need to be generated together.
'';
default = { }; default = { };
type = lib.types.attrsOf ( type = lib.types.attrsOf (
lib.types.submodule (service: { lib.types.submodule (service: {
@ -82,6 +92,9 @@
''; '';
}; };
generator = lib.mkOption { generator = lib.mkOption {
description = ''
The generator to generate the secrets and facts for this service.
'';
type = lib.types.submodule ( type = lib.types.submodule (
{ config, ... }: { config, ... }:
{ {
@ -151,6 +164,9 @@
); );
}; };
secret = lib.mkOption { secret = lib.mkOption {
description = ''
Secret facts to generate for this service.
'';
default = { }; default = { };
type = lib.types.attrsOf ( type = lib.types.attrsOf (
lib.types.submodule (secret: { lib.types.submodule (secret: {
@ -182,11 +198,11 @@
}; };
}) })
); );
description = ''
path where the secret is located in the filesystem
'';
}; };
public = lib.mkOption { public = lib.mkOption {
description = ''
Public facts to generate for this service.
'';
default = { }; default = { };
type = lib.types.attrsOf ( type = lib.types.attrsOf (
lib.types.submodule (fact: { lib.types.submodule (fact: {
@ -208,6 +224,9 @@
config.clan.core.clanDir + "/machines/${config.clan.core.machineName}/facts/${fact.config.name}"; config.clan.core.clanDir + "/machines/${config.clan.core.machineName}/facts/${fact.config.name}";
}; };
value = lib.mkOption { value = lib.mkOption {
description = ''
The value of the public fact.
'';
defaultText = lib.literalExpression "\${config.clan.core.clanDir}/\${fact.config.path}"; defaultText = lib.literalExpression "\${config.clan.core.clanDir}/\${fact.config.path}";
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
default = default =
@ -231,15 +250,5 @@
./public/in_repo.nix ./public/in_repo.nix
./public/vm.nix ./public/vm.nix
# (lib.mkRenamedOptionModule
# [
# "clanCore"
# ]
# [
# "clan"
# "core"
# ]
# )
]; ];
} }

View File

@ -7,6 +7,9 @@
{ {
# interface # interface
options.clan.core.state = lib.mkOption { options.clan.core.state = lib.mkOption {
description = ''
Define state directories to backup and restore
'';
default = { }; default = { };
type = lib.types.attrsOf ( type = lib.types.attrsOf (
lib.types.submodule ( lib.types.submodule (

View File

@ -64,6 +64,9 @@
publicDirectory = lib.mkOption { publicDirectory = lib.mkOption {
type = lib.types.nullOr lib.types.path; type = lib.types.nullOr lib.types.path;
default = null; default = null;
description = ''
The directory where public facts are stored.
'';
}; };
}; };
} }