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.

pennae 8b7f0e55 ef413e3e

Changed files
+33 -60
nixos
+33 -59
nixos/doc/manual/default.nix
···
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"
''
<toc role="chunk-toc">
···
'';
manual-combined = runCommand "nixos-manual-combined"
-
{ inherit sources;
-
nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ];
meta.description = "The NixOS manual as plain docbook XML";
}
''
-
${copySources}
xmllint --xinclude --output ./manual-combined.xml ./manual.xml
···
'';
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 ];
meta.description = "The NixOS manual in HTML format";
allowedReferences = ["out"];
}
···
manualHTMLIndex = "${manualHTML}/share/doc/nixos/index.html";
manualEpub = runCommand "nixos-manual-epub"
-
{ inherit sources;
-
nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin buildPackages.zip ];
}
''
# Generate the epub manual.
···
optionIdPrefix = "test-opt-";
};
toc = builtins.toFile "toc.xml"
''
<toc role="chunk-toc">
···
'';
manual-combined = runCommand "nixos-manual-combined"
+
{ 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";
}
''
+
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
···
'';
in rec {
inherit (optionsDoc) optionsJSON optionsNix optionsDocBook optionsUsedDocbook;
# Generate the NixOS manual.
manualHTML = runCommand "nixos-manual-html"
+
{ nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ];
meta.description = "The NixOS manual in HTML format";
allowedReferences = ["out"];
}
···
manualHTMLIndex = "${manualHTML}/share/doc/nixos/index.html";
manualEpub = runCommand "nixos-manual-epub"
+
{ nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin buildPackages.zip ];
}
''
# Generate the epub manual.
-1
nixos/release.nix
···
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;
···
manual = manualHTML; # TODO(@oxij): remove eventually
manualEpub = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualEpub));
manpages = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manpages);
options = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux;