fix(extranix): ensure default entry exists and escape html
All checks were successful
Check meta / check_dns (pull_request) Successful in 19s
Check meta / check_meta (pull_request) Successful in 20s
Check workflows / check_workflows (pull_request) Successful in 32s
Build all the nodes / ap01 (pull_request) Successful in 1m35s
Build all the nodes / bridge01 (pull_request) Successful in 2m4s
Build all the nodes / geo01 (pull_request) Successful in 2m18s
Build all the nodes / hypervisor01 (pull_request) Successful in 2m7s
Build all the nodes / geo02 (pull_request) Successful in 2m19s
Build all the nodes / hypervisor02 (pull_request) Successful in 1m35s
Build all the nodes / netcore02 (pull_request) Successful in 34s
Build all the nodes / hypervisor03 (pull_request) Successful in 1m33s
Build all the nodes / compute01 (pull_request) Successful in 4m6s
Build all the nodes / rescue01 (pull_request) Successful in 2m15s
Build all the nodes / storage01 (pull_request) Successful in 2m20s
Build all the nodes / tower01 (pull_request) Successful in 1m49s
Build all the nodes / vault01 (pull_request) Successful in 2m5s
Build the shell / build-shell (pull_request) Successful in 32s
Run pre-commit on all files / pre-commit (pull_request) Successful in 36s
Build all the nodes / web02 (pull_request) Successful in 1m45s
Build all the nodes / web01 (pull_request) Successful in 2m24s
Build all the nodes / web03 (pull_request) Successful in 1m47s
Build all the nodes / ap01 (push) Successful in 1m20s
Build all the nodes / bridge01 (push) Successful in 2m20s
Build all the nodes / geo01 (push) Successful in 2m22s
Build all the nodes / hypervisor01 (push) Successful in 2m24s
Build all the nodes / geo02 (push) Successful in 2m24s
Build all the nodes / netcore02 (push) Successful in 28s
Build all the nodes / hypervisor02 (push) Successful in 1m36s
Build all the nodes / compute01 (push) Successful in 3m14s
Build all the nodes / hypervisor03 (push) Successful in 1m39s
Build all the nodes / tower01 (push) Successful in 1m40s
Build all the nodes / storage01 (push) Successful in 2m12s
Build all the nodes / rescue01 (push) Successful in 2m15s
Build all the nodes / vault01 (push) Successful in 1m57s
Build the shell / build-shell (push) Successful in 39s
Run pre-commit on all files / pre-commit (push) Successful in 42s
Build all the nodes / web02 (push) Successful in 1m44s
Build all the nodes / web01 (push) Successful in 2m23s
Build all the nodes / web03 (push) Successful in 1m40s

This commit is contained in:
catvayor 2025-01-04 13:08:26 +01:00
parent 1eac1ec486
commit 2551da6388
Signed by: lbailly
GPG key ID: CE3E645251AC63F3
2 changed files with 29 additions and 9 deletions

View file

@ -92,7 +92,7 @@ in
title = "DGNum module documentation"; title = "DGNum module documentation";
languageCode = "en-us"; languageCode = "en-us";
params = { params = {
release_current_stable = "infra-DGNum"; release_current_stable = "DGNum-Infrastructure";
logo = "images/dgnum.png"; logo = "images/dgnum.png";
footer_credits_line = '' footer_credits_line = ''
Based on <a href="https://github.com/mipmip/home-manager-option-search">Home Manager Option Search</a> Based on <a href="https://github.com/mipmip/home-manager-option-search">Home Manager Option Search</a>

View file

@ -12,6 +12,8 @@ let
inherit (lib) inherit (lib)
attrNames attrNames
concatMapStringsSep concatMapStringsSep
concatStringsSep
escapeXML
filter filter
getExe getExe
hasPrefix hasPrefix
@ -20,6 +22,7 @@ let
importJSON importJSON
mapAttrs' mapAttrs'
mapAttrsToList mapAttrsToList
mkDefault
mkEnableOption mkEnableOption
mkIf mkIf
mkOption mkOption
@ -100,13 +103,13 @@ let
type type
readOnly readOnly
loc loc
description
; ;
descriptionHTML = pkgs.runCommand "option-${title}.html" { } '' descriptionHTML = pkgs.runCommand "option-${title}.html" { } ''
${getExe pkgs.pandoc} -f markdown ${pkgs.writeText "option-${title}.md" val.description} > $out ${getExe pkgs.pandoc} -f markdown-raw_html ${pkgs.writeText "option-${title}.md" val.description} > $out
''; '';
example = val.example.text or ""; description = escapeXML val.description;
default = val.default.text or ""; example = escapeXML (val.example.text or "");
default = escapeXML (val.default.text or "");
declarations = map path-translation val.declarations; declarations = map path-translation val.declarations;
}) filtered-opts; }) filtered-opts;
}; };
@ -238,13 +241,14 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
services = { services = {
extranix = { extranix.settings = {
settings = { theme = "extranix-options-search";
theme = "extranix-options-search"; params = {
params.releases = mapAttrsToList (name: _: { releases = mapAttrsToList (name: _: {
inherit name; inherit name;
value = sanitizeDerivationName name; value = sanitizeDerivationName name;
}) cfg.modules; }) cfg.modules;
release_current_stable = mkDefault (head (attrNames options-files));
}; };
}; };
nginx = { nginx = {
@ -252,5 +256,21 @@ in
virtualHosts.${cfg.host}.locations."/".alias = "${webroot}/"; virtualHosts.${cfg.host}.locations."/".alias = "${webroot}/";
}; };
}; };
assertions = [
{
assertion = cfg.modules != { };
message = ''
`services.extranix` can't be enabled without any modules to document.
'';
}
{
assertion = options-files ? ${cfg.settings.params.release_current_stable};
message = ''
`services.extranix.settings.params.release_current_stable` should be the
`sanitizeDerivationName` of a key of `services.extranix.modules`, here one of:
+ ${concatStringsSep "\n + " (attrNames options-files)}
'';
}
];
}; };
} }