summary refs log tree commit diff
path: root/nixos/doc/manual/default.nix
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2016-01-29 19:34:00 +0100
committeraszlig <aszlig@redmoonstudios.org>2016-01-29 20:14:11 +0100
commit6fec28e04313161b0d330fc3a4d3dfa9f85e53f9 (patch)
treee2fa7fb369cb9718f40bb5e532d1c7dc4df22d1d /nixos/doc/manual/default.nix
parent42f1f442e2a4397a1bf7f4a41736892d8aeddafa (diff)
downloadnixpkgs-6fec28e04313161b0d330fc3a4d3dfa9f85e53f9.tar
nixpkgs-6fec28e04313161b0d330fc3a4d3dfa9f85e53f9.tar.gz
nixpkgs-6fec28e04313161b0d330fc3a4d3dfa9f85e53f9.tar.bz2
nixpkgs-6fec28e04313161b0d330fc3a4d3dfa9f85e53f9.tar.lz
nixpkgs-6fec28e04313161b0d330fc3a4d3dfa9f85e53f9.tar.xz
nixpkgs-6fec28e04313161b0d330fc3a4d3dfa9f85e53f9.tar.zst
nixpkgs-6fec28e04313161b0d330fc3a4d3dfa9f85e53f9.zip
nixos-manual: Further simplify stripAnyPrefixes
First of all this fixes an evaluation error I introduced in ae466ba,
which wasn't triggered by any of my own tests against the change because
there are usually no NixOS options that are declared outside of the
<nixpkgs> tree. I renamed the attribute name from "fn" to "fileName"
first and later to "fullPath" but forgot one still occuring "filename".

Thanks to @vcunat for noticing this.

Another thing that he pointed out was that the "stripPrefix" function
can be factored away entirely, because it's very similar to
"removePrefix" in <nixpkgs/lib>.

Unfortunately we can't use "removePrefix" as is, because we need to
account for the final shlash.

So instead of removing it twice and/or retaining "stripPrefix", let's
append a shlash on every "prefixesToStrip" and we can use "removePrefix"
as is.

Tested with:

taalo-build nixos/release.nix -A tests.installer.simple.x86_64-linux

And:

w3m -dump "$(
  nix-build nixos/release.nix -A manual.x86_64-linux
)/share/doc/nixos/options.html"

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Cc: @vcunat
Diffstat (limited to 'nixos/doc/manual/default.nix')
-rw-r--r--nixos/doc/manual/default.nix11
1 files changed, 2 insertions, 9 deletions
diff --git a/nixos/doc/manual/default.nix b/nixos/doc/manual/default.nix
index de3f9a95d95..b4eb3cde81b 100644
--- a/nixos/doc/manual/default.nix
+++ b/nixos/doc/manual/default.nix
@@ -29,15 +29,8 @@ let
   #
   # E.g. if some `options` came from modules in ${pkgs.customModules}/nix,
   # you'd need to include `extraSources = [ pkgs.customModules ]`
-  prefixesToStrip = map toString ([ ../../.. ] ++ extraSources);
-
-  stripPrefix = prefix: fullPath:
-    if substring 0 (stringLength prefix) fullPath == prefix then
-      substring (stringLength prefix + 1) 1000 fullPath
-    else
-      fileName;
-
-  stripAnyPrefixes = fullPath: fold stripPrefix fullPath prefixesToStrip;
+  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');