diff --git a/machines/nixos/compute01/extranix/default.nix b/machines/nixos/compute01/extranix/default.nix index d97bc51..41056b7 100644 --- a/machines/nixos/compute01/extranix/default.nix +++ b/machines/nixos/compute01/extranix/default.nix @@ -92,7 +92,7 @@ in title = "DGNum module documentation"; languageCode = "en-us"; params = { - release_current_stable = "infra-DGNum"; + release_current_stable = "DGNum-Infrastructure"; logo = "images/dgnum.png"; footer_credits_line = '' Based on Home Manager Option Search diff --git a/modules/nixos/extranix/default.nix b/modules/nixos/extranix/default.nix index 4eced53..4618f31 100644 --- a/modules/nixos/extranix/default.nix +++ b/modules/nixos/extranix/default.nix @@ -12,6 +12,8 @@ let inherit (lib) attrNames concatMapStringsSep + concatStringsSep + escapeXML filter getExe hasPrefix @@ -20,6 +22,7 @@ let importJSON mapAttrs' mapAttrsToList + mkDefault mkEnableOption mkIf mkOption @@ -100,13 +103,13 @@ let type readOnly loc - description ; 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 ""; - default = val.default.text or ""; + description = escapeXML val.description; + example = escapeXML (val.example.text or ""); + default = escapeXML (val.default.text or ""); declarations = map path-translation val.declarations; }) filtered-opts; }; @@ -238,13 +241,14 @@ in }; config = mkIf cfg.enable { services = { - extranix = { - settings = { - theme = "extranix-options-search"; - params.releases = mapAttrsToList (name: _: { + extranix.settings = { + theme = "extranix-options-search"; + params = { + releases = mapAttrsToList (name: _: { inherit name; value = sanitizeDerivationName name; }) cfg.modules; + release_current_stable = mkDefault (head (attrNames options-files)); }; }; nginx = { @@ -252,5 +256,21 @@ in 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)} + ''; + } + ]; }; }