summary refs log tree commit diff
path: root/nixos/doc/manual/default.nix
diff options
context:
space:
mode:
authorRyan Artecona <ryanartecona@gmail.com>2016-01-22 14:22:12 -0500
committerRyan Artecona <ryanartecona@gmail.com>2016-01-22 14:22:12 -0500
commite6cd147ae7ae05900ec2ab8ad933bfac7428feac (patch)
tree587d36c4f4e8c3abb6b4c8a74d89fa384fda26d8 /nixos/doc/manual/default.nix
parent194168b7225b341399ccd8948faf2075896033ca (diff)
downloadnixpkgs-e6cd147ae7ae05900ec2ab8ad933bfac7428feac.tar
nixpkgs-e6cd147ae7ae05900ec2ab8ad933bfac7428feac.tar.gz
nixpkgs-e6cd147ae7ae05900ec2ab8ad933bfac7428feac.tar.bz2
nixpkgs-e6cd147ae7ae05900ec2ab8ad933bfac7428feac.tar.lz
nixpkgs-e6cd147ae7ae05900ec2ab8ad933bfac7428feac.tar.xz
nixpkgs-e6cd147ae7ae05900ec2ab8ad933bfac7428feac.tar.zst
nixpkgs-e6cd147ae7ae05900ec2ab8ad933bfac7428feac.zip
nixos manual: allow options from nix packages
Diffstat (limited to 'nixos/doc/manual/default.nix')
-rw-r--r--nixos/doc/manual/default.nix26
1 files changed, 17 insertions, 9 deletions
diff --git a/nixos/doc/manual/default.nix b/nixos/doc/manual/default.nix
index bd558dac971..eb2ceb7fd02 100644
--- a/nixos/doc/manual/default.nix
+++ b/nixos/doc/manual/default.nix
@@ -1,4 +1,4 @@
-{ pkgs, options, version, revision }:
+{ pkgs, options, version, revision, extraSources ? [] }:
 
 with pkgs;
 with pkgs.lib;
@@ -17,19 +17,27 @@ let
 
   # Clean up declaration sites to not refer to the NixOS source tree.
   optionsList' = flip map optionsList (opt: opt // {
-    declarations = map (fn: stripPrefix fn) opt.declarations;
+    declarations = map (fn: stripAnyPrefixes fn) opt.declarations;
   }
   // optionalAttrs (opt ? example) { example = substFunction opt.example; }
   // optionalAttrs (opt ? default) { default = substFunction opt.default; }
   // optionalAttrs (opt ? type) { type = substFunction opt.type; });
 
-  prefix = toString ../../..;
-
-  stripPrefix = fn:
-    if substring 0 (stringLength prefix) fn == prefix then
-      substring (stringLength prefix + 1) 1000 fn
-    else
-      fn;
+  # We need to strip references to /nix/store/* from options,
+  # including any `extraSources` if some modules came from elsewhere,
+  # or else the build will fail.
+  #
+  # E.g. if some `options` came from modules in ${pkgs.customModules}/nix,
+  # you'd need to include `extraSources = [ "#{pkgs.customModules}" ]`
+  herePrefix = toString ../../..;
+  prefixesToStrip = [ herePrefix ] ++ extraSources;
+
+  stripAnyPrefixes = fn:
+    flip (flip fold fn) prefixesToStrip (fn: prefix:
+      if substring 0 (stringLength prefix) fn == prefix then
+        substring (stringLength prefix + 1) 1000 fn
+      else
+        fn);
 
   # Convert the list of options into an XML file.
   optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsList');