diff options
author | aszlig <aszlig@redmoonstudios.org> | 2016-01-29 16:20:22 +0100 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2016-01-29 16:33:19 +0100 |
commit | ae466ba15c2f74cdd621a4fb548813b30cc524e4 (patch) | |
tree | 594f29eaece593b66947eab01492a5071aeb1898 /nixos/doc/manual/default.nix | |
parent | a581f72f222043936e78d1fe8ad09380c46bfa53 (diff) | |
download | nixlib-ae466ba15c2f74cdd621a4fb548813b30cc524e4.tar nixlib-ae466ba15c2f74cdd621a4fb548813b30cc524e4.tar.gz nixlib-ae466ba15c2f74cdd621a4fb548813b30cc524e4.tar.bz2 nixlib-ae466ba15c2f74cdd621a4fb548813b30cc524e4.tar.lz nixlib-ae466ba15c2f74cdd621a4fb548813b30cc524e4.tar.xz nixlib-ae466ba15c2f74cdd621a4fb548813b30cc524e4.tar.zst nixlib-ae466ba15c2f74cdd621a4fb548813b30cc524e4.zip |
nixos-manual: Simplify stripping prefixes
Let's use a simple (unflipped) fold and break out the actual core stripPrefix function from stripAnyPrefixes (I personally love point-less^H^H^H^Hfree style but if I'd be anal I'd even go further and factor away the "fn:"). Also, let's use path as a better name for "fn" (filename), because that's what it is and also cannot be confused with "fn" meaning "function". We now toString all of the prefixes, so there shouldn't be any need to implicily toString the extraSources anymore. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'nixos/doc/manual/default.nix')
-rw-r--r-- | nixos/doc/manual/default.nix | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/nixos/doc/manual/default.nix b/nixos/doc/manual/default.nix index 5a4d36d9dcc0..de3f9a95d95a 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,16 @@ 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 (prefix: fn: - 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 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; # Convert the list of options into an XML file. optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsList'); |