about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-23 19:32:19 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-23 20:08:22 +0200
commit0def73f39074f7a0699b8362a313e16abf291b31 (patch)
treef6032cef61e0b8e65410cdec81bf79b9b7ee3186
parentcaf18545a495d1fd3021522211c598abfa5e500d (diff)
downloadnixlib-0def73f39074f7a0699b8362a313e16abf291b31.tar
nixlib-0def73f39074f7a0699b8362a313e16abf291b31.tar.gz
nixlib-0def73f39074f7a0699b8362a313e16abf291b31.tar.bz2
nixlib-0def73f39074f7a0699b8362a313e16abf291b31.tar.lz
nixlib-0def73f39074f7a0699b8362a313e16abf291b31.tar.xz
nixlib-0def73f39074f7a0699b8362a313e16abf291b31.tar.zst
nixlib-0def73f39074f7a0699b8362a313e16abf291b31.zip
Manual: Don't depend on the absolute path of modules
This ensures that the manual has the same store path regardless of the
directory in which Nixpkgs is stored, and thus can be fetched from the
channel.
-rw-r--r--nixos/doc/manual/default.nix20
-rw-r--r--nixos/doc/manual/options-to-docbook.xsl15
2 files changed, 28 insertions, 7 deletions
diff --git a/nixos/doc/manual/default.nix b/nixos/doc/manual/default.nix
index 7aa59ffdf5dd..52dda551f1ed 100644
--- a/nixos/doc/manual/default.nix
+++ b/nixos/doc/manual/default.nix
@@ -7,9 +7,23 @@ with pkgs.lib;
 
 let
 
-  options' = filter (x: x.visible && !x.internal) (optionAttrSetToDocList options);
-
-  optionsXML = builtins.toFile "options.xml" (builtins.unsafeDiscardStringContext (builtins.toXML options'));
+  # Remove invisible and internal options.
+  options' = filter (opt: opt.visible && !opt.internal) (optionAttrSetToDocList options);
+
+  # Clean up declaration sites to not refer to the NixOS source tree.
+  options'' = flip map options' (opt: opt // {
+    declarations = map (fn: stripPrefix fn) opt.declarations;
+  });
+
+  prefix = toString pkgs.path;
+  
+  stripPrefix = fn:
+    if substring 0 (stringLength prefix) fn == prefix then
+      substring (add (stringLength prefix) 1) 1000 fn
+    else
+      fn;
+
+  optionsXML = builtins.toFile "options.xml" (builtins.unsafeDiscardStringContext (builtins.toXML options''));
 
   optionsDocBook = pkgs.runCommand "options-db.xml" {} ''
     ${pkgs.libxslt}/bin/xsltproc \
diff --git a/nixos/doc/manual/options-to-docbook.xsl b/nixos/doc/manual/options-to-docbook.xsl
index adc6c93c7223..c799eecc0c10 100644
--- a/nixos/doc/manual/options-to-docbook.xsl
+++ b/nixos/doc/manual/options-to-docbook.xsl
@@ -155,8 +155,15 @@
           repository (if it’s a module and we have a revision number),
           or to the local filesystem. -->
           <xsl:choose>
-            <xsl:when test="$revision != 'local' and contains(@value, '/modules/')">
-              <xsl:attribute name="xlink:href">https://github.com/NixOS/nixos/blob/<xsl:value-of select="$revision"/>/modules/<xsl:value-of select="substring-after(@value, '/modules/')"/></xsl:attribute>
+            <xsl:when test="not(starts-with(@value, '/'))">
+              <xsl:choose>
+                <xsl:when test="$revision = 'local'">
+                  <xsl:attribute name="xlink:href">https://github.com/NixOS/nixpkgs/blob/master/<xsl:value-of select="@value"/></xsl:attribute>
+                </xsl:when>
+                <xsl:otherwise>
+                  <xsl:attribute name="xlink:href">https://github.com/NixOS/nixpkgs/blob/<xsl:value-of select="$revision"/>/<xsl:value-of select="@value"/></xsl:attribute>
+                </xsl:otherwise>
+              </xsl:choose>
             </xsl:when>
             <xsl:when test="$revision != 'local' and contains(@value, 'nixops') and contains(@value, '/nix/')">
               <xsl:attribute name="xlink:href">https://github.com/NixOS/nixops/blob/<xsl:value-of select="$revision"/>/nix/<xsl:value-of select="substring-after(@value, '/nix/')"/></xsl:attribute>
@@ -169,8 +176,8 @@
           /nix/store/<hash> prefix by the default location of nixos
           sources. -->
           <xsl:choose>
-            <xsl:when test="contains(@value, '/modules/')">
-              &lt;nixos/modules/<xsl:value-of select="substring-after(@value, '/modules/')"/>&gt;
+            <xsl:when test="not(starts-with(@value, '/'))">
+              &lt;nixpkgs/<xsl:value-of select="@value"/>&gt;
             </xsl:when>
             <xsl:when test="contains(@value, 'nixops') and contains(@value, '/nix/')">
               &lt;nixops/<xsl:value-of select="substring-after(@value, '/nix/')"/>&gt;