diff options
author | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2009-11-07 16:09:04 +0000 |
---|---|---|
committer | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2009-11-07 16:09:04 +0000 |
commit | b901c0e80833d385cc5fc78aa441b343bc1b8645 (patch) | |
tree | d8a9daf5a96c256c0f7635a64d2ad028574de21e /pkgs/lib | |
parent | 8b47086b85cb62a25b6cf167e085c86418a0e399 (diff) | |
download | nixpkgs-b901c0e80833d385cc5fc78aa441b343bc1b8645.tar nixpkgs-b901c0e80833d385cc5fc78aa441b343bc1b8645.tar.gz nixpkgs-b901c0e80833d385cc5fc78aa441b343bc1b8645.tar.bz2 nixpkgs-b901c0e80833d385cc5fc78aa441b343bc1b8645.tar.lz nixpkgs-b901c0e80833d385cc5fc78aa441b343bc1b8645.tar.xz nixpkgs-b901c0e80833d385cc5fc78aa441b343bc1b8645.tar.zst nixpkgs-b901c0e80833d385cc5fc78aa441b343bc1b8645.zip |
* Add an awful hack to bypass the strictness of isType operators for
option definitions. svn path=/nixpkgs/trunk/; revision=18259
Diffstat (limited to 'pkgs/lib')
-rw-r--r-- | pkgs/lib/properties.nix | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/pkgs/lib/properties.nix b/pkgs/lib/properties.nix index 3964c117f14..c7e6a336ee7 100644 --- a/pkgs/lib/properties.nix +++ b/pkgs/lib/properties.nix @@ -441,4 +441,42 @@ rec { in map (x: x.value) (sort cmp rankValList); + /* mkFixStrictness */ + + # This is a hack used to restore laziness on some option definitions. + # Some option definitions are evaluated when they are not used. This + # error is caused by the strictness of type checking builtins. Builtins + # like 'isAttrs' are too strict because they have to evaluate their + # arguments to check if the type is correct. This evaluation, cause the + # strictness of properties. + # + # Properties can be stacked on top of each other. The stackability of + # properties on top of the option definition is nice for user manipulation + # but require to check if the content of the property is not another + # property. Such testing implies to verify if this is an attribute set + # and if it possess the type "property". (see isProperty & typeOf) + # + # To avoid strict evaluation of option definitions, 'mkFixStrictness' is + # introduced. This property protect the option definition by replacing + # the base of the stack of properties by 'mkNotDef', when this property is + # evaluated it returns the original definition. + # + # This property is useful over any elements which may depends on an + # options which may raise an error if it gets evaluated whitout the proper + # settings. You do not need to use this on top of plain list or attribute + # set. + # + # This is a Hack, you should avoid it! + + # This property has a long name because you should avoid it. + isFixStrictness = attrs: (typeOf attrs) == "fix-strictness"; + mkFixStrictness = value: + mkProperty { + property = { + _type = "fix-strictness"; + onEval = p: value; + }; + content = mkNotdef; + }; + } |