From f4b5a21d59e15273fa8025c8e7337ca1469fc2a0 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <eelco.dolstra@logicblox.com>
Date: Fri, 5 Jun 2009 15:04:58 +0000
Subject: [PATCH] * Fix building the manual.

svn path=/nixos/branches/modular-nixos/; revision=15877
---
 doc/manual/default.nix                 | 8 +++++---
 modules/services/misc/nixos-manual.nix | 9 +++++++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/doc/manual/default.nix b/doc/manual/default.nix
index fe22e4f6c8bf..e44dbb56c410 100644
--- a/doc/manual/default.nix
+++ b/doc/manual/default.nix
@@ -1,12 +1,14 @@
-{nixpkgs ? ../../../nixpkgs}:
+{pkgs}:
 
 let
 
-  pkgs = import nixpkgs {};
+  manualConfig =
+    { environment.checkConfigurationOptions = false;
+    };
 
   options = builtins.toFile "options.xml" (builtins.unsafeDiscardStringContext
     (builtins.toXML (pkgs.lib.optionAttrSetToDocList ""
-      (import ../../system/system.nix {inherit nixpkgs; configuration = {};}).optionDeclarations)));
+      (import ../../lib/eval-config.nix {inherit pkgs; configuration = manualConfig;}).optionDeclarations)));
 
   optionsDocBook = pkgs.runCommand "options-db.xml" {} ''
     ${pkgs.libxslt}/bin/xsltproc -o $out ${./options-to-docbook.xsl} ${options} 
diff --git a/modules/services/misc/nixos-manual.nix b/modules/services/misc/nixos-manual.nix
index 9ff0150c921a..fe26591b8ba0 100644
--- a/modules/services/misc/nixos-manual.nix
+++ b/modules/services/misc/nixos-manual.nix
@@ -40,7 +40,9 @@ let
         };
 
         manualFile = mkOption {
-          default = null;
+          # Note: we can't use a default here (see below), since it
+          # causes an infinite recursion building the manual.
+          default = null; 
           description = "
             NixOS manual HTML file
           ";
@@ -59,7 +61,10 @@ in let # !!! Bug in Nix 0.13pre14722, otherwise the following line is not aware
 
   realManualFile =
     if manualFile == null then
-      (import ../doc/manual {nixpkgs = pkgs;})+"/manual.html"
+      # We could speed up the evaluation of the manual expression by
+      # providing it the optionDeclarations of the current
+      # configuration.
+      "${import ../../../doc/manual {inherit pkgs;}}/manual.html"
     else
       manualFile;