about summary refs log tree commit diff
path: root/release.nix
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2018-04-20 13:04:46 +0200
committeraszlig <aszlig@nix.build>2018-04-20 13:04:46 +0200
commitb7e2b621d8a9e2efa2c51ecce0585bee34c8a134 (patch)
treefd900c7a93caa8e0f5f30c1d686d396416c075b9 /release.nix
parente4d2075bfd09c5cba0b555f861a584bcb8f57610 (diff)
release: Fix build of the manual
The changes in NixOS/nixpkgs@4b4bbce199d3b3a8001ee93495604289b0
include moving the style.css to a different location, but they also add
syntax highlighting, so let's include it as well :-)

I've also reorganized the XSLT flags a bit and instead of a big
multiline string we now use an attribute set to define these flags in a
declarative way.

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'release.nix')
-rw-r--r--release.nix38
1 files changed, 27 insertions, 11 deletions
diff --git a/release.nix b/release.nix
index e55b45fa..a717341d 100644
--- a/release.nix
+++ b/release.nix
@@ -172,18 +172,32 @@ in with pkgsUpstream.lib; with builtins; {
     filterDoc = filter (opt: isVuizvui opt && opt.visible && !opt.internal);
     optionsXML = toXML (filterDoc (optionAttrSetToDocList modules.options));
     optionsFile = toFile "options.xml" (unsafeDiscardStringContext optionsXML);
+
+    mkXsltFlags = flags: let
+      mkParam = flag: valFun: opt: val: [ "--${flag}" opt (valFun val) ];
+      mkStrParam = mkParam "stringparam" id;
+      mkBoolParam = mkParam "param" (b: if b then "1" else "0");
+      mkFlag = path: value: let
+        opt = concatStringsSep "." path;
+      in if isString value then mkStrParam opt value
+         else if isBool value then mkBoolParam opt value
+         else throw "Invalid value for '${opt}': ${toString value}";
+      result = collect isList (mapAttrsRecursive mkFlag flags);
+    in concatMapStringsSep " " escapeShellArg (concatLists result);
+
+    xsltFlags = mkXsltFlags {
+      section.autolabel = true;
+      section.label.includes.component.label = true;
+      html.stylesheet = "style.css overrides.css highlightjs/mono-blue.css";
+      html.script = "highlightjs/highlight.pack.js highlightjs/loader.js";
+      xref."with".number.and.title = true;
+      admon.style = "";
+    };
+
   in pkgsUpstream.stdenv.mkDerivation {
     name = "vuizvui-options";
 
-    buildInputs = singleton pkgsUpstream.libxslt;
-
-    xsltFlags = ''
-      --param section.autolabel 1
-      --param section.label.includes.component.label 1
-      --param html.stylesheet 'style.css'
-      --param xref.with.number.and.title 1
-      --param admon.style '''
-    '';
+    nativeBuildInputs = singleton pkgsUpstream.libxslt;
 
     buildCommand = ''
       cp -r "${./doc}" doc
@@ -195,11 +209,13 @@ in with pkgsUpstream.lib; with builtins; {
       dest="$out/share/doc/vuizvui"
       mkdir -p "$dest"
 
-      xsltproc -o "$dest/" $xsltFlags -nonet -xinclude \
+      xsltproc -o "$dest/" ${xsltFlags} -nonet -xinclude \
         ${patchedDocbookXSL}/xml/xsl/docbook/xhtml/chunk.xsl \
         doc/index.xml
 
-      cp "${nixpkgs}/nixos/doc/manual/style.css" "$dest/style.css"
+      cp "${nixpkgs}/doc/style.css" "$dest/style.css"
+      cp "${nixpkgs}/doc/overrides.css" "$dest/overrides.css"
+      cp -r ${pkgsUpstream.documentation-highlighter} "$dest/highlightjs"
 
       mkdir -p "$out/nix-support"
       echo "doc manual $dest" > "$out/nix-support/hydra-build-products"