diff options
| author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-01-25 10:43:39 +0100 |
|---|---|---|
| committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-01-25 10:43:39 +0100 |
| commit | 310aadc48b6771a0737e3c3b7f6a96120cf8e8f8 (patch) | |
| tree | e4801d80017fc899bcab59ebc19a639942aa67b9 | |
| parent | Merge pull request #12590 from exi/askpass-in-env (diff) | |
| parent | nixos manual: allow options from nix packages (diff) | |
| download | nixpkgs-310aadc48b6771a0737e3c3b7f6a96120cf8e8f8.tar.gz | |
Merge pull request #12557 from ryanartecona/nixos-manual-custom-options
NixOS manual: allow options from nix packages
| -rw-r--r-- | nixos/doc/manual/default.nix | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/nixos/doc/manual/default.nix b/nixos/doc/manual/default.nix index bd558dac971d..eb2ceb7fd021 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 ../../..; + # 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; - stripPrefix = fn: - if substring 0 (stringLength prefix) fn == prefix then - substring (stringLength prefix + 1) 1000 fn - else - fn; + 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'); |
