From a4a9ae9e12746eb244b584d42b51893b11841338 Mon Sep 17 00:00:00 2001 From: catvayor Date: Wed, 11 Dec 2024 23:27:47 +0100 Subject: [PATCH] feat(son): add DGN infra doc --- machines/kat-son/configuration.nix | 68 ++++++++++++++++++++++++------ machines/kat-son/doc/default.nix | 25 +++++++++-- 2 files changed, 76 insertions(+), 17 deletions(-) diff --git a/machines/kat-son/configuration.nix b/machines/kat-son/configuration.nix index d472767..0338b6a 100644 --- a/machines/kat-son/configuration.nix +++ b/machines/kat-son/configuration.nix @@ -1,6 +1,7 @@ { lib, pkgs, + modulesPath, ... }: { @@ -78,26 +79,67 @@ }; extranix = { enable = true; - modules."netconf" = let - netconf = pkgs.fetchgit { - url = "https://git.dgnum.eu/DGNum/Netconf-Module.git"; - rev = "8f58ee21fe9c0ad22e3f16e58c3837c1c97eb5e8"; - outputHash = "sha256-OXKSFEOjeeRFVbVodJSkhuT+r7+p6QPUzjbw2vs6Xao="; - name = "netconf"; - }; - in { - paths = [ "${netconf.outPath}/junos" "${netconf.outPath}/dgn-module.nix" ]; - base = netconf.outPath; - url = "https://git.dgnum.eu/DGNum/Netconf-Module/src/branch/master/"; + modules = { + "netconf" = + let + netconf = pkgs.fetchgit { + url = "https://git.dgnum.eu/DGNum/Netconf-Module.git"; + rev = "8f58ee21fe9c0ad22e3f16e58c3837c1c97eb5e8"; + outputHash = "sha256-OXKSFEOjeeRFVbVodJSkhuT+r7+p6QPUzjbw2vs6Xao="; + name = "netconf"; + }; + in + { + paths = [ + "${netconf.outPath}/junos" + "${netconf.outPath}/dgn-module.nix" + ]; + base = netconf.outPath; + url = "https://git.dgnum.eu/DGNum/Netconf-Module/src/branch/master/"; + }; + "infra DGNum" = + let + infra = pkgs.fetchgit { + url = "https://git.dgnum.eu/DGNum/infrastructure.git"; + rev = "417ce615079ca26e1251e7f0b6b24c36b293a17d"; + outputHash = "sha256-LhjQoVZqYARpUxuuWhcNY7HLE64H8PIIBZ0QwlmGD2I="; + name = "DGN-infra"; + }; + in + { + paths = [ + "${infra}/modules/generic" + "${infra}/modules/nixos" + ]; + ignored-modules = import "${modulesPath}/module-list.nix"; + specialArgs = { + lib = lib // { + extra = import "${infra}/lib/nix-lib"; + }; + inherit pkgs modulesPath; + name = ""; + nodeMeta = { + nix-modules = [ ]; + admins = [ ]; + adminGroups = [ ]; + }; + meta = { + organization.groups.root = [ ]; + }; + sources = (import "${infra}/hive.nix").meta.specialArgs.sources; + }; + base = infra.outPath; + url = "https://git.dgnum.eu/DGNum/infrastructure/src/branch/main/"; + }; }; static-data = ./static-data; host = "son.katvayor.net"; settings = { baseUrl = "https://dgnum.eu/"; - title = "DGNum netconf module documentation"; + title = "DGNum module documentation"; languageCode = "en-us"; params = { - release_current_stable = "netconf"; + release_current_stable = "infra-DGNum"; logo = "images/dgnum.png"; footer_credits_line = '' Powered by catvayor | diff --git a/machines/kat-son/doc/default.nix b/machines/kat-son/doc/default.nix index c510d80..ea7775f 100644 --- a/machines/kat-son/doc/default.nix +++ b/machines/kat-son/doc/default.nix @@ -11,12 +11,12 @@ let mkIf types importJSON - filterAttrs mapAttrs' mapAttrsToList removePrefix pathIsDirectory hasSuffix + attrNames ; inherit (lib.strings) sanitizeDerivationName @@ -28,10 +28,19 @@ let module-eval = module: let - eval = lib.evalModules { modules = module.paths; }; + ignored-eval = lib.evalModules { + modules = module.ignored-modules; + inherit (module) specialArgs; + }; + ignored-opts-doc = pkgs.nixosOptionsDoc { inherit (ignored-eval) options; }; + ignored-opts = importJSON "${ignored-opts-doc.optionsJSON}/share/doc/nixos/options.json"; + eval = lib.evalModules { + modules = module.paths ++ module.ignored-modules; + inherit (module) specialArgs; + }; opts-doc = pkgs.nixosOptionsDoc { inherit (eval) options; }; - val = importJSON "${opts-doc.optionsJSON}/share/doc/nixos/options.json"; - filtered-opts = filterAttrs (name: _: name != "_module.args") val; + opts = importJSON "${opts-doc.optionsJSON}/share/doc/nixos/options.json"; + filtered-opts = removeAttrs opts (attrNames ignored-opts); result = json.generate "options-extranix.json" { last_update = "-/-"; options = mapAttrsToList (title: val: { @@ -81,9 +90,17 @@ in type = let module-mod.options = { + specialArgs = mkOption { + type = types.attrs; + default = { }; + }; paths = mkOption { type = types.listOf types.path; }; + ignored-modules = mkOption { + type = types.listOf types.deferredModule; + default = [ ]; + }; base = mkOption { type = types.path; };