From 8b7f0e559ad9419815d0a4c8d231e2bf464c0ad2 Mon Sep 17 00:00:00 2001 From: pennae Date: Sun, 12 Feb 2023 09:40:07 +0100 Subject: [PATCH] nixos/manual: clean up default.nix a bit - inline copySources into single user - remove `inherit sources` where it's not necessary - inline generatedSources. this will go away completely soon so we may as well. - inline modulesDoc into manual-combined. this too will go away soon. - inline sources into manual-combined. this too will go away soon. --- nixos/doc/manual/default.nix | 92 +++++++++++++----------------------- nixos/release.nix | 1 - 2 files changed, 33 insertions(+), 60 deletions(-) diff --git a/nixos/doc/manual/default.nix b/nixos/doc/manual/default.nix index 30f1f51b3878..3da6e88c70b7 100644 --- a/nixos/doc/manual/default.nix +++ b/nixos/doc/manual/default.nix @@ -68,56 +68,6 @@ let optionIdPrefix = "test-opt-"; }; - sources = runCommand "manual-sources" { - inputs = lib.sourceFilesBySuffices ./. [ ".xml" ".md" ]; - nativeBuildInputs = [ pkgs.nixos-render-docs ]; - } '' - mkdir $out - cd $out - cp -r --no-preserve=all $inputs/* . - - declare -a convert_args - while read -r mf; do - if [[ "$mf" = *.chapter.md ]]; then - convert_args+=("--chapter") - else - convert_args+=("--section") - fi - - convert_args+=("from_md/''${mf%.md}.xml" "$mf") - done < <(find . -type f -name '*.md') - - nixos-render-docs manual docbook-fragment \ - --manpage-urls ${manpageUrls} \ - "''${convert_args[@]}" - ''; - - modulesDoc = runCommand "modules.xml" { - nativeBuildInputs = [ pkgs.nixos-render-docs ]; - } '' - nixos-render-docs manual docbook-section \ - --manpage-urls ${manpageUrls} \ - "$out" \ - --section \ - --section-id modules \ - --chapters ${lib.concatMapStrings (p: "${p.value} ") config.meta.doc} - ''; - - generatedSources = runCommand "generated-docbook" {} '' - mkdir $out - ln -s ${modulesDoc} $out/modules.xml - ln -s ${optionsDoc.optionsDocBook} $out/options-db.xml - ln -s ${testOptionsDoc.optionsDocBook} $out/test-options-db.xml - printf "%s" "${version}" > $out/version - ''; - - copySources = - '' - cp -prd $sources/* . # */ - ln -s ${generatedSources} ./generated - chmod -R u+w . - ''; - toc = builtins.toFile "toc.xml" '' @@ -186,12 +136,40 @@ let ''; manual-combined = runCommand "nixos-manual-combined" - { inherit sources; - nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ]; + { inputs = lib.sourceFilesBySuffices ./. [ ".xml" ".md" ]; + nativeBuildInputs = [ pkgs.nixos-render-docs pkgs.libxml2.bin pkgs.libxslt.bin ]; meta.description = "The NixOS manual as plain docbook XML"; } '' - ${copySources} + cp -r --no-preserve=all $inputs/* . + + declare -a convert_args + while read -r mf; do + if [[ "$mf" = *.chapter.md ]]; then + convert_args+=("--chapter") + else + convert_args+=("--section") + fi + + convert_args+=("from_md/''${mf%.md}.xml" "$mf") + done < <(find . -type f -name '*.md') + + nixos-render-docs manual docbook-fragment \ + --manpage-urls ${manpageUrls} \ + "''${convert_args[@]}" + + mkdir ./generated + ln -s ${optionsDoc.optionsDocBook} ./generated/options-db.xml + ln -s ${testOptionsDoc.optionsDocBook} ./generated/test-options-db.xml + printf "%s" "${version}" > ./generated/version + chmod -R u+w . + + nixos-render-docs manual docbook-section \ + --manpage-urls ${manpageUrls} \ + ./generated/modules.xml \ + --section \ + --section-id modules \ + --chapters ${lib.concatMapStrings (p: "${p.value} ") config.meta.doc} xmllint --xinclude --output ./manual-combined.xml ./manual.xml @@ -220,14 +198,11 @@ let ''; in rec { - inherit generatedSources; - inherit (optionsDoc) optionsJSON optionsNix optionsDocBook optionsUsedDocbook; # Generate the NixOS manual. manualHTML = runCommand "nixos-manual-html" - { inherit sources; - nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ]; + { nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ]; meta.description = "The NixOS manual in HTML format"; allowedReferences = ["out"]; } @@ -264,8 +239,7 @@ in rec { manualHTMLIndex = "${manualHTML}/share/doc/nixos/index.html"; manualEpub = runCommand "nixos-manual-epub" - { inherit sources; - nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin buildPackages.zip ]; + { nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin buildPackages.zip ]; } '' # Generate the epub manual. diff --git a/nixos/release.nix b/nixos/release.nix index 946379bcd661..78a74af41242 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -144,7 +144,6 @@ in rec { manual = manualHTML; # TODO(@oxij): remove eventually manualEpub = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualEpub)); manpages = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manpages); - manualGeneratedSources = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.generatedSources); options = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux;