1
0
Fork 0
mirror of https://github.com/NixOS/nix-pills synced 2024-09-19 04:00:13 -04:00
nix-pills/default.nix

87 lines
2.4 KiB
Nix
Raw Normal View History

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;
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
2017-08-11 18:22:51 -04:00
xmllint --xinclude --output $out ./book.xml
'';
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"
"--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'"
"--stringparam chunk.toc ${toc}"
];
in pkgs.stdenv.mkDerivation {
name = "nix-pills";
src = sources;
buildInputs = with pkgs; [ jing libxslt ];
installPhase = ''
jing ${pkgs.docbook5}/xml/rng/docbook/docbook.rng $combined
# Generate the HTML manual.
2017-08-12 17:57:40 -04:00
dst=$out/share/doc/nix-pills
2017-08-11 18:22:51 -04:00
mkdir -p $dst
xsltproc \
${manualXsltprocOptions} \
--nonet --output $dst/ \
${pkgs.docbook5_xsl}/xml/xsl/docbook/xhtml/chunk.xsl \
2017-08-11 18:22:51 -04:00
${combined}
mkdir -p $dst/images
cp -r ${pkgs.docbook5_xsl}/xml/xsl/docbook/images/callouts $dst/images/callouts
cp ${./style.css} $dst/style.css
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
'';
}