2017-08-19 10:56:31 -04:00
|
|
|
{ pkgs ? import <nixpkgs> {}, revCount, shortRev }:
|
2017-08-11 18:22:51 -04:00
|
|
|
let
|
|
|
|
lib = pkgs.lib;
|
2018-02-23 18:26:47 -05:00
|
|
|
|
|
|
|
sources = let
|
|
|
|
|
|
|
|
# We want nix examples, but not the top level nix to build things
|
|
|
|
noTopLevelNix = path: type: let
|
|
|
|
relPath = lib.removePrefix (toString ./. + "/") (toString path);
|
|
|
|
in builtins.match "[^/]*\.nix" relPath == null;
|
|
|
|
|
|
|
|
extensions = [ ".xml" ".txt" ".nix" ".bash" ];
|
|
|
|
|
|
|
|
in lib.cleanSourceWith {
|
|
|
|
filter = noTopLevelNix;
|
|
|
|
src = lib.sourceFilesBySuffices ./. extensions;
|
|
|
|
};
|
2017-08-11 18:22:51 -04:00
|
|
|
|
|
|
|
combined = pkgs.runCommand "nix-pills-combined"
|
|
|
|
{
|
|
|
|
buildInputs = [ pkgs.libxml2 ];
|
|
|
|
meta.description = "Nix Pills with as a single docbook file";
|
2017-08-19 10:56:31 -04:00
|
|
|
inherit revCount shortRev;
|
2017-08-11 18:22:51 -04:00
|
|
|
}
|
|
|
|
''
|
|
|
|
cp -r ${sources} ./sources
|
|
|
|
chmod -R u+w ./sources
|
|
|
|
|
|
|
|
cd sources
|
|
|
|
|
2017-08-19 10:56:31 -04:00
|
|
|
printf "%s-%s" "$revCount" "$shortRev" > version
|
2021-12-15 15:18:25 -05:00
|
|
|
xmllint --xinclude --output "$out" ./book.xml
|
2017-08-11 18:22:51 -04:00
|
|
|
'';
|
|
|
|
|
|
|
|
toc = builtins.toFile "toc.xml"
|
|
|
|
''
|
|
|
|
<toc role="chunk-toc">
|
|
|
|
<d:tocentry xmlns:d="http://docbook.org/ns/docbook" linkend="book-nix-pills"><?dbhtml filename="index.html"?>
|
|
|
|
</d:tocentry>
|
|
|
|
</toc>
|
|
|
|
'';
|
|
|
|
|
|
|
|
manualXsltprocOptions = toString [
|
2017-08-12 22:31:35 -04:00
|
|
|
"--param section.autolabel 1"
|
2017-08-11 18:22:51 -04:00
|
|
|
"--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 ''"
|
2017-08-12 17:57:40 -04:00
|
|
|
"--stringparam callout.graphics.extension .svg"
|
2017-08-16 20:51:29 -04:00
|
|
|
"--stringparam current.docid nix-pills"
|
2017-08-11 18:22:51 -04:00
|
|
|
"--param chunk.section.depth 0"
|
|
|
|
"--param chunk.first.sections 1"
|
|
|
|
"--param use.id.as.filename 1"
|
|
|
|
"--stringparam generate.toc 'book toc appendix toc'"
|
2021-12-15 15:18:25 -05:00
|
|
|
"--stringparam chunk.toc '${toc}'"
|
2017-08-11 18:22:51 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
in pkgs.stdenv.mkDerivation {
|
|
|
|
name = "nix-pills";
|
|
|
|
|
|
|
|
src = sources;
|
2021-12-15 15:13:12 -05:00
|
|
|
buildInputs = with pkgs; [ libxslt ];
|
2017-08-11 18:22:51 -04:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
# Generate the HTML manual.
|
2017-08-12 17:57:40 -04:00
|
|
|
dst=$out/share/doc/nix-pills
|
2021-12-15 15:18:25 -05:00
|
|
|
mkdir -p "$dst"
|
2017-08-11 18:22:51 -04:00
|
|
|
xsltproc \
|
|
|
|
${manualXsltprocOptions} \
|
2021-12-15 15:18:25 -05:00
|
|
|
--nonet --output "$dst/" \
|
|
|
|
"${pkgs.docbook-xsl-ns}/xml/xsl/docbook/xhtml/chunk.xsl" \
|
|
|
|
"${combined}"
|
2017-08-11 18:22:51 -04:00
|
|
|
|
2021-12-15 15:19:49 -05:00
|
|
|
mkdir -p "$dst/images/callouts"
|
|
|
|
cp -r "${pkgs.docbook-xsl-ns}/xml/xsl/docbook/images/callouts"/*.svg "$dst/images/callouts"
|
2017-08-11 18:22:51 -04:00
|
|
|
|
2021-12-15 15:18:25 -05:00
|
|
|
cp "${./style.css}" "$dst/style.css"
|
2017-08-11 18:22:51 -04:00
|
|
|
|
2021-12-15 15:18:25 -05:00
|
|
|
mkdir -p "$out/nix-support"
|
|
|
|
echo "nix-build out $out" >> "$out/nix-support/hydra-build-products"
|
|
|
|
echo "doc nix-pills $dst" >> "$out/nix-support/hydra-build-products"
|
2017-08-11 18:22:51 -04:00
|
|
|
'';
|
|
|
|
}
|