docs: render module options docs
All checks were successful
checks / check-links (pull_request) Successful in 14s
checks / checks (pull_request) Successful in 3m46s
checks / checks-impure (pull_request) Successful in 1m49s

fix errors while rendering some modules
This commit is contained in:
DavHau 2024-03-27 16:47:24 +07:00
parent ec105d8ef8
commit e0bdf1ce39
6 changed files with 96 additions and 28 deletions

View File

@ -28,6 +28,7 @@ in
default = "ssh -i ${
config.clanCore.facts.services.borgbackup.secret."borgbackup.ssh".path
} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null";
defaultText = "ssh -i \${config.clanCore.facts.services.borgbackup.secret.\"borgbackup.ssh\".path} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null";
description = "the rsh to use for the backup";
};
};

View File

@ -17,28 +17,22 @@
package = lib.mkPackageOption pkgs "localsend" { };
};
imports =
if config.clan.localsend.enable then
[
{
clanCore.state.localsend.folders = [
"/var/localsend"
config.clan.localsend.defaultLocation
];
environment.systemPackages = [ config.clan.localsend.package ];
config = lib.mkIf config.clan.localsend.enable {
clanCore.state.localsend.folders = [
"/var/localsend"
config.clan.localsend.defaultLocation
];
environment.systemPackages = [ config.clan.localsend.package ];
networking.firewall.interfaces."zt+".allowedTCPPorts = [ 53317 ];
networking.firewall.interfaces."zt+".allowedUDPPorts = [ 53317 ];
networking.firewall.interfaces."zt+".allowedTCPPorts = [ 53317 ];
networking.firewall.interfaces."zt+".allowedUDPPorts = [ 53317 ];
#TODO: This is currently needed because there is no ipv6 multicasting support yet
#
systemd.network.networks."09-zerotier" = {
networkConfig = {
Address = "192.168.56.2/24";
};
};
}
]
else
[ ];
#TODO: This is currently needed because there is no ipv6 multicasting support yet
#
systemd.network.networks."09-zerotier" = {
networkConfig = {
Address = "192.168.56.2/24";
};
};
};
}

View File

@ -10,6 +10,7 @@
type = lib.types.nullOr lib.types.str;
example = "BABNJY4-G2ICDLF-QQEG7DD-N3OBNGF-BCCOFK6-MV3K7QJ-2WUZHXS-7DTW4AS";
default = config.clanCore.facts.services.syncthing.public."syncthing.pub".value or null;
defaultText = "config.clanCore.facts.services.syncthing.public.\"syncthing.pub\".value";
};
introducer = lib.mkOption {
description = ''

72
docs/flake-module.nix Normal file
View File

@ -0,0 +1,72 @@
{
self,
lib,
inputs,
...
}:
{
perSystem =
{ pkgs, ... }:
let
allNixosModules = (import "${inputs.nixpkgs}/nixos/modules/module-list.nix") ++ [
"${inputs.nixpkgs}/nixos/modules/misc/assertions.nix"
{ nixpkgs.hostPlatform = "x86_64-linux"; }
];
clanCoreNixosModules = [ self.nixosModules.clanCore ] ++ allNixosModules;
# options = modules: (inputs.nixpkgs.legacyPackages.x86_64-linux.nixos { imports = modules; }).options;
options =
modules:
(lib.evalModules {
modules = modules;
# modules = modules ++ ["${inputs.nixpkgs}/nixos/modules/misc/assertions.nix"];
# specialArgs = { pkgs = pkgs; };
}).options;
docs =
options:
pkgs.nixosOptionsDoc {
options = options;
warningsAreErrors = false;
transformOptions =
opt:
opt
// {
declarations = lib.forEach opt.declarations (
decl:
if lib.hasPrefix "${self}" decl then
let
subpath = lib.removePrefix "${self}" decl;
in
{
url = "https://git.clan.lol/clan/clan-core/src/branch/main/" + subpath;
name = subpath;
}
else
decl
);
};
};
outputsFor = name: docs: { packages."docs-md-${name}" = docs.optionsCommonMark; };
clanModulesPages = lib.flip lib.mapAttrsToList self.clanModules (
name: module:
outputsFor "module-${name}" (
docs (options ([ module ] ++ clanCoreNixosModules)).clan.${name} or { }
)
);
in
{
imports =
clanModulesPages
# uncomment to render clanCore top-level options as extra pages
# ++ clanCorePages
++ [
# renders all clanCore options as a single page
(outputsFor "core-options" (docs (options clanCoreNixosModules).clanCore))
];
};
}

View File

@ -34,15 +34,14 @@
];
imports = [
./checks/flake-module.nix
./devShell.nix
./formatter.nix
./templates/flake-module.nix
./clanModules/flake-module.nix
./pkgs/flake-module.nix
./devShell.nix
./docs/flake-module.nix
./formatter.nix
./lib/flake-module.nix
./nixosModules/flake-module.nix
./pkgs/flake-module.nix
./templates/flake-module.nix
{
options.flake = flake-parts.lib.mkSubmoduleOptions {
clanInternals = lib.mkOption {

View File

@ -40,6 +40,7 @@
)
];
options.clanCore.secrets = lib.mkOption {
visible = false;
default = { };
type = lib.types.attrsOf (
lib.types.submodule (service: {