fix(son-doc): file miss in documentation

This commit is contained in:
catvayor 2024-12-12 14:11:49 +01:00
parent a4a9ae9e12
commit 02c565bb9d
Signed by: lbailly
GPG key ID: CE3E645251AC63F3
2 changed files with 83 additions and 29 deletions

View file

@ -1,7 +1,6 @@
{
lib,
pkgs,
modulesPath,
...
}:
{
@ -94,8 +93,12 @@
"${netconf.outPath}/junos"
"${netconf.outPath}/dgn-module.nix"
];
base = netconf.outPath;
url = "https://git.dgnum.eu/DGNum/Netconf-Module/src/branch/master/";
path-translations = [
{
base = netconf.outPath;
url = "https://git.dgnum.eu/DGNum/Netconf-Module/src/branch/master/";
}
];
};
"infra DGNum" =
let
@ -105,18 +108,27 @@
outputHash = "sha256-LhjQoVZqYARpUxuuWhcNY7HLE64H8PIIBZ0QwlmGD2I=";
name = "DGN-infra";
};
infra-hive = import "${infra}/hive.nix";
infra-source = infra-hive.meta.specialArgs.sources;
infra-nixpkgs = infra-hive.meta.nixpkgs { };
infra-modulesPath = "${infra-nixpkgs.path}/nixos/modules/";
in
{
paths = [
"${infra}/modules/generic"
"${infra}/modules/nixos"
];
ignored-modules = import "${modulesPath}/module-list.nix";
ignored-modules = import "${infra-modulesPath}/module-list.nix" ++ [
"${infra-source.agenix}/modules/age.nix"
"${infra-source.arkheon}/module.nix"
"${infra-source."microvm.nix"}/nixos-modules/host"
];
specialArgs = {
lib = lib // {
lib = infra-nixpkgs.lib // {
extra = import "${infra}/lib/nix-lib";
};
inherit pkgs modulesPath;
modulesPath = infra-modulesPath;
pkgs = infra-nixpkgs;
name = "<nodeName>";
nodeMeta = {
nix-modules = [ ];
@ -126,10 +138,26 @@
meta = {
organization.groups.root = [ ];
};
sources = (import "${infra}/hive.nix").meta.specialArgs.sources;
sources = infra-source;
};
base = infra.outPath;
url = "https://git.dgnum.eu/DGNum/infrastructure/src/branch/main/";
path-translations = [
{
base = infra.outPath;
url = "https://git.dgnum.eu/DGNum/infrastructure/src/branch/main/";
}
{
base = infra-source.nix-modules;
url = "https://git.hubrecht.ovh/hubrecht/nix-modules/src/branch/main/";
}
{
base = infra-modulesPath;
url = "https://github.com/NixOS/nixpkgs/tree/master/nixos/modules";
}
{
base = infra-source.cgroup-exporter;
url = "https://github.com/arianvp/cgroup-exporter/blob/main/";
}
];
};
};
static-data = ./static-data;

View file

@ -16,7 +16,10 @@ let
removePrefix
pathIsDirectory
hasSuffix
hasPrefix
attrNames
filter
head
;
inherit (lib.strings)
sanitizeDerivationName
@ -26,7 +29,7 @@ let
cfg = config.services.extranix;
module-eval =
module:
module-name: module:
let
ignored-eval = lib.evalModules {
modules = module.ignored-modules;
@ -41,6 +44,33 @@ let
opts-doc = pkgs.nixosOptionsDoc { inherit (eval) options; };
opts = importJSON "${opts-doc.optionsJSON}/share/doc/nixos/options.json";
filtered-opts = removeAttrs opts (attrNames ignored-opts);
path-translation =
let
translations = map (
{ base, url }:
{
url = "${url}${if hasSuffix "/" url then "" else "/"}";
base =
let
base1 = toString base;
in
base1 + (if hasSuffix "/" base1 then "" else "/");
}
) module.path-translations;
in
path:
let
fullPath = path + (if pathIsDirectory path then "/default.nix" else "");
fitting = filter ({ base, ... }: hasPrefix base fullPath) translations;
translate-info = head (
fitting ++ [ (throw "${fullPath} is not in any base path of ${module-name}") ]
);
innerPath = removePrefix translate-info.base fullPath;
in
{
name = "<${innerPath}>";
url = "${translate-info.url}${innerPath}";
};
result = json.generate "options-extranix.json" {
last_update = "-/-";
options = mapAttrsToList (title: val: {
@ -53,19 +83,7 @@ let
;
example = val.example.text or "";
default = val.default.text or "";
declarations = map (
decl:
let
baseString1 = toString module.base;
baseString = baseString1 + (if hasSuffix "/" baseString1 then "" else "/");
innerPath1 = if pathIsDirectory decl then decl + "/default.nix" else decl;
innerPath = removePrefix baseString innerPath1;
in
{
name = "<${innerPath}>";
url = "${module.url}${if hasSuffix "/" module.url then "" else "/"}${innerPath}";
}
) val.declarations;
declarations = map path-translation val.declarations;
}) filtered-opts;
};
in
@ -73,7 +91,7 @@ let
options-files = mapAttrs' (name: value: {
name = sanitizeDerivationName name;
value = module-eval value;
value = module-eval name value;
}) cfg.modules;
webroot = pkgs.callPackage ./webroot.nix {
@ -101,11 +119,19 @@ in
type = types.listOf types.deferredModule;
default = [ ];
};
base = mkOption {
type = types.path;
};
url = mkOption {
type = types.str;
path-translations = mkOption {
type =
let
path-mod.options = {
base = mkOption {
type = types.path;
};
url = mkOption {
type = types.str;
};
};
in
types.listOf (types.submodule path-mod);
};
};
in