Manual: Handle XML files in subdirectories

This commit is contained in:
Eelco Dolstra 2014-08-25 14:33:17 +02:00
parent 8cfd9b1acd
commit b1ce3cc172
2 changed files with 18 additions and 14 deletions

View file

@ -21,12 +21,12 @@ rec {
# Get all files ending with the specified suffices from the given # Get all files ending with the specified suffices from the given
# directory. E.g. `sourceFilesBySuffices ./dir [".xml" ".c"]'. # directory or its descendants. E.g. `sourceFilesBySuffices ./dir
# [".xml" ".c"]'.
sourceFilesBySuffices = path: exts: sourceFilesBySuffices = path: exts:
let filter = name: type: let filter = name: type:
let base = baseNameOf (toString name); let base = baseNameOf (toString name);
in type != "directory" && lib.any (ext: lib.hasSuffix ext base) exts; in type == "directory" || lib.any (ext: lib.hasSuffix ext base) exts;
in builtins.filterSource filter path; in builtins.filterSource filter path;
} }

View file

@ -36,13 +36,22 @@ let
-o $out ${./options-to-docbook.xsl} ${optionsXML} -o $out ${./options-to-docbook.xsl} ${optionsXML}
''; '';
sources = sourceFilesBySuffices ./. [".xml"];
copySources =
''
cp -prd $sources/* . # */
ln -s ${optionsDocBook} options-db.xml
echo "${version}" > version
'';
in rec { in rec {
# Generate the NixOS manual. # Generate the NixOS manual.
manual = stdenv.mkDerivation { manual = stdenv.mkDerivation {
name = "nixos-manual"; name = "nixos-manual";
sources = sourceFilesBySuffices ./. [".xml"]; inherit sources;
buildInputs = [ libxml2 libxslt ]; buildInputs = [ libxml2 libxslt ];
@ -57,9 +66,7 @@ in rec {
''; '';
buildCommand = '' buildCommand = ''
ln -s $sources/*.xml . # */ ${copySources}
ln -s ${optionsDocBook} options-db.xml
echo "${version}" > version
# Check the validity of the manual sources. # Check the validity of the manual sources.
xmllint --noout --nonet --xinclude --noxincludenode \ xmllint --noout --nonet --xinclude --noxincludenode \
@ -90,7 +97,7 @@ in rec {
manualPDF = stdenv.mkDerivation { manualPDF = stdenv.mkDerivation {
name = "nixos-manual-pdf"; name = "nixos-manual-pdf";
sources = sourceFilesBySuffices ./. [".xml"]; inherit sources;
buildInputs = [ libxml2 libxslt dblatex tetex ]; buildInputs = [ libxml2 libxslt dblatex tetex ];
@ -98,9 +105,7 @@ in rec {
# TeX needs a writable font cache. # TeX needs a writable font cache.
export VARTEXFONTS=$TMPDIR/texfonts export VARTEXFONTS=$TMPDIR/texfonts
ln -s $sources/*.xml . # */ ${copySources}
ln -s ${optionsDocBook} options-db.xml
echo "${version}" > version
dst=$out/share/doc/nixos dst=$out/share/doc/nixos
mkdir -p $dst mkdir -p $dst
@ -117,13 +122,12 @@ in rec {
manpages = stdenv.mkDerivation { manpages = stdenv.mkDerivation {
name = "nixos-manpages"; name = "nixos-manpages";
sources = sourceFilesBySuffices ./. [".xml"]; inherit sources;
buildInputs = [ libxml2 libxslt ]; buildInputs = [ libxml2 libxslt ];
buildCommand = '' buildCommand = ''
ln -s $sources/*.xml . # */ ${copySources}
ln -s ${optionsDocBook} options-db.xml
# Check the validity of the manual sources. # Check the validity of the manual sources.
xmllint --noout --nonet --xinclude --noxincludenode \ xmllint --noout --nonet --xinclude --noxincludenode \