From 645fa542ee26c8e0151a8ceaa81b196ceff5eaa9 Mon Sep 17 00:00:00 2001 From: Sk7Str1p3 Date: Sun, 26 Jul 2026 18:31:29 +0000 Subject: [PATCH 1/6] refactor(docs): allow excluded directories overriding --- docs/docgen.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/docgen.nix b/docs/docgen.nix index 227bd56..9838327 100644 --- a/docs/docgen.nix +++ b/docs/docgen.nix @@ -3,6 +3,11 @@ mdbook, nixdoc, lib, + excluded ? [ + ".*flake\\.nix$" + + "^docs/.*" + ] }: stdenvNoCC.mkDerivation { name = "SkyOS-book"; @@ -13,12 +18,6 @@ stdenvNoCC.mkDerivation { ]; patchPhase = let - excluded = [ - ".*flake\\.nix$" - - "^docs/.*" - ]; - shouldExclude = relPath: lib.any (pattern: builtins.match pattern relPath != null) excluded; nixFiles = From 7d3133cc3c9f24b21d7394ea3b8230a34631c569 Mon Sep 17 00:00:00 2001 From: Sk7Str1p3 Date: Sun, 26 Jul 2026 18:49:40 +0000 Subject: [PATCH 2/6] refactor(docs): cleanup variables --- docs/docgen.nix | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/docs/docgen.nix b/docs/docgen.nix index 9838327..c502528 100644 --- a/docs/docgen.nix +++ b/docs/docgen.nix @@ -18,33 +18,23 @@ stdenvNoCC.mkDerivation { ]; patchPhase = let - shouldExclude = relPath: lib.any (pattern: builtins.match pattern relPath != null) excluded; - + relPath = file: lib.removePrefix (toString ../. + "/") (toString file); nixFiles = with lib.fileset; - let - allFiles = toList (fileFilter (f: f.hasExt "nix") ../.); - in - lib.filter ( - file: - let - relPath = lib.removePrefix (toString ../. + "/") (toString file); - in - !shouldExclude relPath - ) allFiles; + lib.filter (file: !(lib.any (pattern: builtins.match pattern (relPath file) != null) excluded)) ( + toList (fileFilter (f: f.hasExt "nix") ../.) + ); chapters = lib.sort (a: b: a.sortKey < b.sortKey) ( map ( file: let - - relPath = lib.removePrefix (toString ../. + "/") (toString file); mdPath = ( if baseNameOf file == "default.nix" then - lib.removeSuffix "/" (dirOf relPath) + lib.removeSuffix "/" (dirOf (relPath file)) else - lib.removeSuffix ".nix" relPath + lib.removeSuffix ".nix" (relPath file) ) + ".md"; @@ -55,7 +45,7 @@ stdenvNoCC.mkDerivation { hosts = 3; users = 4; }; - order = orderMap.${lib.head (lib.splitString "/" relPath)}; + order = orderMap.${lib.head (lib.splitString "/" (relPath file))}; category = lib.removeSuffix ".md" (lib.replaceStrings [ "/" ] [ "." ] mdPath); title = From 403cd57c219b4ada300da91486ca16569d45c5a5 Mon Sep 17 00:00:00 2001 From: Sk7Str1p3 Date: Sun, 26 Jul 2026 19:04:33 +0000 Subject: [PATCH 3/6] format(docs): newlines --- docs/docgen.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/docgen.nix b/docs/docgen.nix index c502528..20f230c 100644 --- a/docs/docgen.nix +++ b/docs/docgen.nix @@ -7,15 +7,18 @@ ".*flake\\.nix$" "^docs/.*" - ] + ], }: + stdenvNoCC.mkDerivation { name = "SkyOS-book"; src = ./.; + nativeBuildInputs = [ mdbook nixdoc ]; + patchPhase = let relPath = file: lib.removePrefix (toString ../. + "/") (toString file); From 4b91758f0710a959b36a2a5292833745ea367db3 Mon Sep 17 00:00:00 2001 From: Sk7Str1p3 Date: Sun, 26 Jul 2026 19:09:46 +0000 Subject: [PATCH 4/6] feat(docs): modules docgen --- docs/docgen.nix | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/docgen.nix b/docs/docgen.nix index 20f230c..a1b37b9 100644 --- a/docs/docgen.nix +++ b/docs/docgen.nix @@ -2,6 +2,7 @@ stdenvNoCC, mdbook, nixdoc, + nixosOptionsDoc, lib, excluded ? [ ".*flake\\.nix$" @@ -45,8 +46,9 @@ stdenvNoCC.mkDerivation { docs = 0; flake = 1; devShells = 2; - hosts = 3; - users = 4; + modules = 3; + hosts = 4; + users = 5; }; order = orderMap.${lib.head (lib.splitString "/" (relPath file))}; @@ -66,6 +68,18 @@ stdenvNoCC.mkDerivation { in if dirPart == "." then 0 else lib.length (lib.splitString "/" dirPart); indent = lib.concatStringsSep "" (lib.genList (x: " ") depth); + + isModule = (r: lib.hasPrefix "modules/os" r || lib.hasPrefix "modules/home" r) relPath; + modulesEval = lib.evalModules { + modules = [ + file + { _module.check = false; } + ]; + }; + moduleOptionsDoc = + (nixosOptionsDoc { + options = lib.removeAttrs modulesEval.options [ "_module" ]; + }).optionsCommonMark; in { script = '' @@ -76,6 +90,12 @@ stdenvNoCC.mkDerivation { --description "${title}" \ --anchor-prefix "" \ --file "${file}" > "src/${mdPath}" + '' + + lib.optionalString isModule '' + { + echo + cat ${moduleOptionsDoc} + } >> src/${mdPath} ''; summaryLine = "${indent}- [${title}](${mdPath})"; sortKey = toString order + mdPath; From e0270ad02844899cfe21d7322bb2df6c50927c0b Mon Sep 17 00:00:00 2001 From: Sk7Str1p3 Date: Sun, 26 Jul 2026 19:11:27 +0000 Subject: [PATCH 5/6] chore(docs): docgen logs --- docs/docgen.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docgen.nix b/docs/docgen.nix index a1b37b9..c81ed02 100644 --- a/docs/docgen.nix +++ b/docs/docgen.nix @@ -84,6 +84,7 @@ stdenvNoCC.mkDerivation { { script = '' mkdir -p "src/${dirOf mdPath}" + echo "Documenting ${file} > src/${mdPath}" nixdoc \ --prefix "" \ --category "${category}" \ @@ -92,6 +93,7 @@ stdenvNoCC.mkDerivation { --file "${file}" > "src/${mdPath}" '' + lib.optionalString isModule '' + echo "Adding modules documentation for ${file} > src/${mdPath}" { echo cat ${moduleOptionsDoc} From 69c741e87a9c7cadb1fc4040356e2ffe1e0aacfd Mon Sep 17 00:00:00 2001 From: Sk7Str1p3 Date: Sun, 26 Jul 2026 19:13:51 +0000 Subject: [PATCH 6/6] fix(docs): call `realPath` --- docs/docgen.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docgen.nix b/docs/docgen.nix index c81ed02..b63b181 100644 --- a/docs/docgen.nix +++ b/docs/docgen.nix @@ -69,7 +69,7 @@ stdenvNoCC.mkDerivation { if dirPart == "." then 0 else lib.length (lib.splitString "/" dirPart); indent = lib.concatStringsSep "" (lib.genList (x: " ") depth); - isModule = (r: lib.hasPrefix "modules/os" r || lib.hasPrefix "modules/home" r) relPath; + isModule = (r: lib.hasPrefix "modules/os" r || lib.hasPrefix "modules/home" r) (relPath file); modulesEval = lib.evalModules { modules = [ file