diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2010-05-12 11:07:49 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2010-05-12 11:07:49 +0000 |
commit | 9ec34da2ee947930621f68b1856a636b46391ed4 (patch) | |
tree | a0bd17d186f1d99e1d02fc52f528fa5a37eb3f53 | |
parent | da7e1fbea30140a517fe822814ba2e39b07b5cd4 (diff) | |
download | nixlib-9ec34da2ee947930621f68b1856a636b46391ed4.tar nixlib-9ec34da2ee947930621f68b1856a636b46391ed4.tar.gz nixlib-9ec34da2ee947930621f68b1856a636b46391ed4.tar.bz2 nixlib-9ec34da2ee947930621f68b1856a636b46391ed4.tar.lz nixlib-9ec34da2ee947930621f68b1856a636b46391ed4.tar.xz nixlib-9ec34da2ee947930621f68b1856a636b46391ed4.tar.zst nixlib-9ec34da2ee947930621f68b1856a636b46391ed4.zip |
* In the generation of the `options.xml' file used to produce the
NixOS manual and manpages, remove all derivation attributes except the `name' attribute. This cuts the size of `options.xml' from 7.0 MiB to 473 KiB, and more importantly, cuts evaluation time of the system derivation from 1.63s to 1.10s on my laptop (a 32% improvement). svn path=/nixpkgs/trunk/; revision=21739
-rw-r--r-- | pkgs/lib/options.nix | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/pkgs/lib/options.nix b/pkgs/lib/options.nix index d975f904085f..38dfb106ff5c 100644 --- a/pkgs/lib/options.nix +++ b/pkgs/lib/options.nix @@ -262,8 +262,8 @@ rec { declarations = map (x: toString x.source) opt.declarations; definitions = map (x: toString x.source) opt.definitions; } - // optionalAttrs (opt ? example) { example = opt.example; } - // optionalAttrs (opt ? default) { default = opt.default; }; + // optionalAttrs (opt ? example) { example = scrubOptionValue opt.example; } + // optionalAttrs (opt ? default) { default = scrubOptionValue opt.default; }; subOptions = if opt ? options then @@ -275,4 +275,16 @@ rec { ) [] options; + /* This function recursively removes all derivation attributes from + `x' except for the `name' attribute. This is to make the + generation of `options.xml' much more efficient: the XML + representation of derivations is very large (on the order of + megabytes) and is not actually used by the manual generator. */ + scrubOptionValue = x: + if isDerivation x then { type = "derivation"; drvPath = x.name; name = x.name; } + else if isList x then map scrubOptionValue x + else if isAttrs x then mapAttrs (n: v: scrubOptionValue v) x + else x; + + } |