2013-11-01 19:44:03 +04:00
|
|
|
{ pkgs, options, version, revision }:
|
2008-06-05 19:33:17 +04:00
|
|
|
|
2014-08-09 18:30:44 +04:00
|
|
|
with pkgs;
|
2013-10-17 16:09:05 +04:00
|
|
|
with pkgs.lib;
|
|
|
|
|
2011-09-14 22:20:50 +04:00
|
|
|
let
|
2009-10-06 03:15:06 +04:00
|
|
|
|
2013-10-23 21:32:19 +04:00
|
|
|
# Remove invisible and internal options.
|
2014-08-27 13:53:08 +04:00
|
|
|
optionsList = filter (opt: opt.visible && !opt.internal) (optionAttrSetToDocList options);
|
|
|
|
|
|
|
|
# Replace functions by the string <function>
|
|
|
|
substFunction = x:
|
|
|
|
if builtins.isAttrs x then mapAttrs (name: substFunction) x
|
|
|
|
else if builtins.isList x then map substFunction x
|
|
|
|
else if builtins.isFunction x then "<function>"
|
|
|
|
else x;
|
2013-10-23 21:32:19 +04:00
|
|
|
|
|
|
|
# Clean up declaration sites to not refer to the NixOS source tree.
|
2014-08-27 13:53:08 +04:00
|
|
|
optionsList' = flip map optionsList (opt: opt // {
|
2013-10-23 21:32:19 +04:00
|
|
|
declarations = map (fn: stripPrefix fn) opt.declarations;
|
2014-08-27 13:53:08 +04:00
|
|
|
}
|
|
|
|
// optionalAttrs (opt ? example) { example = substFunction opt.example; }
|
2015-01-04 17:40:59 +03:00
|
|
|
// optionalAttrs (opt ? default) { default = substFunction opt.default; }
|
|
|
|
// optionalAttrs (opt ? type) { type = substFunction opt.type; });
|
2013-10-23 21:32:19 +04:00
|
|
|
|
2014-06-13 18:46:59 +04:00
|
|
|
prefix = toString ../../..;
|
2013-10-23 22:06:17 +04:00
|
|
|
|
2013-10-23 21:32:19 +04:00
|
|
|
stripPrefix = fn:
|
|
|
|
if substring 0 (stringLength prefix) fn == prefix then
|
2014-06-13 18:46:59 +04:00
|
|
|
substring (stringLength prefix + 1) 1000 fn
|
2013-10-23 21:32:19 +04:00
|
|
|
else
|
|
|
|
fn;
|
|
|
|
|
2014-11-17 15:41:18 +03:00
|
|
|
# Convert the list of options into an XML file. The builtin
|
|
|
|
# unsafeDiscardStringContext is used to prevent the realisation of
|
|
|
|
# the store paths which are used in options definitions.
|
2014-08-27 13:53:08 +04:00
|
|
|
optionsXML = builtins.toFile "options.xml" (builtins.unsafeDiscardStringContext (builtins.toXML optionsList'));
|
2008-01-04 17:24:42 +03:00
|
|
|
|
2014-08-09 18:30:44 +04:00
|
|
|
optionsDocBook = runCommand "options-db.xml" {} ''
|
2014-11-17 15:41:18 +03:00
|
|
|
optionsXML=${optionsXML}
|
2014-08-27 13:53:08 +04:00
|
|
|
if grep /nixpkgs/nixos/modules $optionsXML; then
|
2013-10-23 22:06:17 +04:00
|
|
|
echo "The manual appears to depend on the location of Nixpkgs, which is bad"
|
|
|
|
echo "since this prevents sharing via the NixOS channel. This is typically"
|
|
|
|
echo "caused by an option default that refers to a relative path (see above"
|
|
|
|
echo "for hints about the offending path)."
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-08-09 18:30:44 +04:00
|
|
|
${libxslt}/bin/xsltproc \
|
2009-10-06 03:47:50 +04:00
|
|
|
--stringparam revision '${revision}' \
|
2014-08-27 13:53:08 +04:00
|
|
|
-o $out ${./options-to-docbook.xsl} $optionsXML
|
2008-01-04 17:24:42 +03:00
|
|
|
'';
|
2009-09-18 19:10:37 +04:00
|
|
|
|
2014-08-25 16:33:17 +04:00
|
|
|
sources = sourceFilesBySuffices ./. [".xml"];
|
|
|
|
|
|
|
|
copySources =
|
|
|
|
''
|
|
|
|
cp -prd $sources/* . # */
|
2014-08-27 14:24:10 +04:00
|
|
|
chmod -R u+w .
|
|
|
|
cp ${../../modules/services/databases/postgresql.xml} configuration/postgresql.xml
|
2014-08-25 16:33:17 +04:00
|
|
|
ln -s ${optionsDocBook} options-db.xml
|
|
|
|
echo "${version}" > version
|
|
|
|
'';
|
|
|
|
|
2015-07-22 17:09:00 +03:00
|
|
|
toc = builtins.toFile "toc.xml"
|
|
|
|
''
|
|
|
|
<toc role="chunk-toc">
|
|
|
|
<d:tocentry xmlns:d="http://docbook.org/ns/docbook" linkend="book-nixos-manual"><?dbhtml filename="index.html"?>
|
2015-07-22 17:17:06 +03:00
|
|
|
<d:tocentry linkend="ch-options"><?dbhtml filename="options.html"?></d:tocentry>
|
|
|
|
<d:tocentry linkend="ch-release-notes"><?dbhtml filename="release-notes.html"?></d:tocentry>
|
2015-07-22 17:09:00 +03:00
|
|
|
</d:tocentry>
|
|
|
|
</toc>
|
|
|
|
'';
|
|
|
|
|
2010-08-11 16:28:53 +04:00
|
|
|
in rec {
|
|
|
|
|
2014-11-17 15:41:18 +03:00
|
|
|
# The NixOS options in JSON format.
|
|
|
|
optionsJSON = stdenv.mkDerivation {
|
|
|
|
name = "options-json";
|
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
# Export list of options in different format.
|
|
|
|
dst=$out/share/doc/nixos
|
|
|
|
mkdir -p $dst
|
|
|
|
|
2014-11-17 15:44:52 +03:00
|
|
|
cp ${builtins.toFile "options.json" (builtins.unsafeDiscardStringContext (builtins.toJSON
|
2014-11-17 15:58:23 +03:00
|
|
|
(listToAttrs (map (o: { name = o.name; value = removeAttrs o ["name" "visible" "internal"]; }) optionsList'))))
|
2014-11-17 15:44:52 +03:00
|
|
|
} $dst/options.json
|
2014-11-17 15:41:18 +03:00
|
|
|
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
echo "file json $dst/options.json" >> $out/nix-support/hydra-build-products
|
|
|
|
''; # */
|
|
|
|
|
|
|
|
meta.description = "List of NixOS options in JSON format";
|
|
|
|
};
|
2014-08-27 13:53:08 +04:00
|
|
|
|
2010-08-11 16:28:53 +04:00
|
|
|
# Generate the NixOS manual.
|
2014-08-09 18:30:44 +04:00
|
|
|
manual = stdenv.mkDerivation {
|
2008-01-04 17:24:42 +03:00
|
|
|
name = "nixos-manual";
|
|
|
|
|
2014-08-25 16:33:17 +04:00
|
|
|
inherit sources;
|
2008-01-04 17:24:42 +03:00
|
|
|
|
2014-08-09 18:30:44 +04:00
|
|
|
buildInputs = [ libxml2 libxslt ];
|
2008-01-04 17:24:42 +03:00
|
|
|
|
|
|
|
buildCommand = ''
|
2014-08-25 16:33:17 +04:00
|
|
|
${copySources}
|
2009-07-14 19:47:03 +04:00
|
|
|
|
2009-10-05 17:17:45 +04:00
|
|
|
# Check the validity of the manual sources.
|
|
|
|
xmllint --noout --nonet --xinclude --noxincludenode \
|
2014-08-09 18:30:44 +04:00
|
|
|
--relaxng ${docbook5}/xml/rng/docbook/docbook.rng \
|
2009-10-05 17:17:45 +04:00
|
|
|
manual.xml
|
|
|
|
|
|
|
|
# Generate the HTML manual.
|
2009-07-14 19:47:03 +04:00
|
|
|
dst=$out/share/doc/nixos
|
2014-06-30 16:56:10 +04:00
|
|
|
mkdir -p $dst
|
2014-08-25 21:08:12 +04:00
|
|
|
xsltproc \
|
|
|
|
--param section.autolabel 1 \
|
|
|
|
--param section.label.includes.component.label 1 \
|
|
|
|
--stringparam html.stylesheet style.css \
|
|
|
|
--param xref.with.number.and.title 1 \
|
|
|
|
--param toc.section.depth 3 \
|
|
|
|
--stringparam admon.style "" \
|
|
|
|
--stringparam callout.graphics.extension .gif \
|
2014-08-27 14:24:10 +04:00
|
|
|
--param chunk.section.depth 0 \
|
2014-08-25 21:08:12 +04:00
|
|
|
--param chunk.first.sections 1 \
|
|
|
|
--param use.id.as.filename 1 \
|
2015-07-22 17:09:00 +03:00
|
|
|
--stringparam generate.toc "book toc appendix toc" \
|
|
|
|
--stringparam chunk.toc ${toc} \
|
2014-08-25 21:08:12 +04:00
|
|
|
--nonet --xinclude --output $dst/ \
|
2015-07-22 17:09:00 +03:00
|
|
|
${docbook5_xsl}/xml/xsl/docbook/xhtml/chunktoc.xsl ./manual.xml
|
2009-09-18 19:10:37 +04:00
|
|
|
|
2012-07-25 19:54:24 +04:00
|
|
|
mkdir -p $dst/images/callouts
|
2014-08-09 18:30:44 +04:00
|
|
|
cp ${docbook5_xsl}/xml/xsl/docbook/images/callouts/*.gif $dst/images/callouts/
|
2013-01-09 16:43:57 +04:00
|
|
|
|
2009-07-14 19:47:03 +04:00
|
|
|
cp ${./style.css} $dst/style.css
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2013-10-24 22:06:02 +04:00
|
|
|
mkdir -p $out/nix-support
|
|
|
|
echo "nix-build out $out" >> $out/nix-support/hydra-build-products
|
2014-09-10 17:03:49 +04:00
|
|
|
echo "doc manual $dst" >> $out/nix-support/hydra-build-products
|
2012-07-25 19:54:24 +04:00
|
|
|
''; # */
|
2013-10-24 22:06:02 +04:00
|
|
|
|
|
|
|
meta.description = "The NixOS manual in HTML format";
|
2010-08-11 16:28:53 +04:00
|
|
|
};
|
|
|
|
|
2014-08-09 18:30:44 +04:00
|
|
|
manualPDF = stdenv.mkDerivation {
|
|
|
|
name = "nixos-manual-pdf";
|
|
|
|
|
2014-08-25 16:33:17 +04:00
|
|
|
inherit sources;
|
2014-08-09 18:30:44 +04:00
|
|
|
|
|
|
|
buildInputs = [ libxml2 libxslt dblatex tetex ];
|
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
# TeX needs a writable font cache.
|
|
|
|
export VARTEXFONTS=$TMPDIR/texfonts
|
|
|
|
|
2014-08-25 16:33:17 +04:00
|
|
|
${copySources}
|
2014-08-09 18:30:44 +04:00
|
|
|
|
|
|
|
dst=$out/share/doc/nixos
|
|
|
|
mkdir -p $dst
|
|
|
|
xmllint --xinclude manual.xml | dblatex -o $dst/manual.pdf - \
|
|
|
|
-P doc.collab.show=0 \
|
|
|
|
-P latex.output.revhistory=0
|
|
|
|
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
echo "doc-pdf manual $dst/manual.pdf" >> $out/nix-support/hydra-build-products
|
|
|
|
''; # */
|
|
|
|
};
|
|
|
|
|
2010-08-11 16:28:53 +04:00
|
|
|
# Generate the NixOS manpages.
|
2014-08-09 18:30:44 +04:00
|
|
|
manpages = stdenv.mkDerivation {
|
2010-08-11 16:28:53 +04:00
|
|
|
name = "nixos-manpages";
|
|
|
|
|
2014-08-25 16:33:17 +04:00
|
|
|
inherit sources;
|
2010-08-11 16:28:53 +04:00
|
|
|
|
2014-08-09 18:30:44 +04:00
|
|
|
buildInputs = [ libxml2 libxslt ];
|
2010-08-11 16:28:53 +04:00
|
|
|
|
|
|
|
buildCommand = ''
|
2014-08-25 16:33:17 +04:00
|
|
|
${copySources}
|
2010-08-11 16:28:53 +04:00
|
|
|
|
|
|
|
# Check the validity of the manual sources.
|
|
|
|
xmllint --noout --nonet --xinclude --noxincludenode \
|
2014-08-09 18:30:44 +04:00
|
|
|
--relaxng ${docbook5}/xml/rng/docbook/docbook.rng \
|
2010-08-11 16:28:53 +04:00
|
|
|
./man-pages.xml
|
2009-07-14 19:47:03 +04:00
|
|
|
|
2009-10-05 17:17:45 +04:00
|
|
|
# Generate manpages.
|
2013-10-24 22:06:02 +04:00
|
|
|
mkdir -p $out/share/man
|
2009-07-14 19:47:03 +04:00
|
|
|
xsltproc --nonet --xinclude \
|
|
|
|
--param man.output.in.separate.dir 1 \
|
|
|
|
--param man.output.base.dir "'$out/share/man/'" \
|
2009-10-06 03:15:06 +04:00
|
|
|
--param man.endnotes.are.numbered 0 \
|
2014-08-09 18:30:44 +04:00
|
|
|
${docbook5_xsl}/xml/xsl/docbook/manpages/docbook.xsl \
|
2009-07-14 19:47:03 +04:00
|
|
|
./man-pages.xml
|
2008-01-04 17:24:42 +03:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2011-09-14 22:20:50 +04:00
|
|
|
}
|