about summary refs log tree commit diff
path: root/nixos/doc/manual/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/doc/manual/default.nix')
-rw-r--r--nixos/doc/manual/default.nix15
1 files changed, 4 insertions, 11 deletions
diff --git a/nixos/doc/manual/default.nix b/nixos/doc/manual/default.nix
index eb2ceb7fd021..b4eb3cde81bf 100644
--- a/nixos/doc/manual/default.nix
+++ b/nixos/doc/manual/default.nix
@@ -17,7 +17,7 @@ let
 
   # Clean up declaration sites to not refer to the NixOS source tree.
   optionsList' = flip map optionsList (opt: opt // {
-    declarations = map (fn: stripAnyPrefixes fn) opt.declarations;
+    declarations = map stripAnyPrefixes opt.declarations;
   }
   // optionalAttrs (opt ? example) { example = substFunction opt.example; }
   // optionalAttrs (opt ? default) { default = substFunction opt.default; }
@@ -28,16 +28,9 @@ let
   # 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);
+  # you'd need to include `extraSources = [ pkgs.customModules ]`
+  prefixesToStrip = map (p: "${toString p}/") ([ ../../.. ] ++ extraSources);
+  stripAnyPrefixes = flip (fold removePrefix) prefixesToStrip;
 
   # Convert the list of options into an XML file.
   optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsList');