3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/lib
Maximilian Bosch 7203788068
lib/generators: withRecursion: don't break attr-sets with special attrs
Closes #168327

The issue reported there can be demonstrated with the following
expression:

    → nix-instantiate --eval -E "with import ./. {}; pkgs.lib.options.showDefs [ { file = \"foo\"; value = pkgs.rust.packages.stable.buildRustPackages; } ]"
    error: attempt to call something which is not a function but a string

           at /home/ma27/Projects/nixpkgs/lib/trivial.nix:442:35:

              441|   isFunction = f: builtins.isFunction f ||
              442|     (f ? __functor && isFunction (f.__functor f));
                 |                                   ^
              443|

Basically, if a `__functor` is in an attribute-set at depth-limit,
`__functor` will be set to `"<unevaluated>"`. This however breaks
`lib.isFunction` which checks for a `__functor` by invoking `__functor`
with `f` itself.

The same issue - "magic" attributes being shadowed by `withRecursion` -
also applies to others such as
`__pretty`/`__functionArgs`/`__toString`.

Since these attributes have a low-risk of causing a stack overflow
(because these are flat attr-sets or even functions), ignoring them in
`withRecursion` seems like a valid solution.
2022-04-12 12:34:23 +02:00
..
systems Ericson2314's suggestion here: https://github.com/NixOS/nixpkgs/pull/161158#discussion_r822295406 2022-03-10 20:30:19 -08:00
tests lib/generators: withRecursion: don't break attr-sets with special attrs 2022-04-12 12:34:23 +02:00
asserts.nix lib/asserts: use throw to display message for assertMsg 2022-01-19 00:50:06 +01:00
attrsets.nix Merge pull request #147077 from Infinisil/updateAttrPaths 2022-03-19 19:00:03 +01:00
cli.nix
customisation.nix lib/customization: Improve callPackage error message for missing args 2022-04-01 22:03:05 +02:00
debug.nix
default.nix lib/trivial: actually expose warnIfNot and throwIf 2022-03-27 16:48:33 +02:00
deprecated.nix
fetchers.nix
filesystem.nix
fixed-points.nix lib.compose{Many,}Extensions: Make compatible with nix flake check 2021-08-26 09:12:17 -04:00
flake.nix Fix import path. 2021-08-14 14:46:00 -05:00
generators.nix lib/generators: withRecursion: don't break attr-sets with special attrs 2022-04-12 12:34:23 +02:00
kernel.nix
licenses.nix Merge pull request #165672 from yoctocell/patatt-init 2022-03-27 14:53:39 +02:00
lists.nix lib.lists: Use builtins.groupBy for lib.groupBy 2022-03-18 00:05:10 +01:00
meta.nix lib/meta: fix typo in platformMatch comment 2022-01-24 12:54:22 -03:00
minver.nix
modules.nix Merge pull request #165540 from Infinisil/module-args-docs 2022-04-05 21:51:46 +02:00
options.nix Merge remote-tracking branch 'origin/master' into haskell-updates 2022-03-26 09:59:28 +01:00
sources.nix lib.sources: Improve docs 2022-01-30 02:04:51 +01:00
strings-with-deps.nix
strings.nix Merge pull request #166383 from hercules-ci/always-sanitize-derivation-name 2022-04-05 20:05:33 +02:00
trivial.nix Merge pull request #164660 from ncfavier/tests-restrict-arguments 2022-03-24 17:01:47 +01:00
types.nix lib/modules: Finally remove deprecated types.optionSet 2022-03-18 04:51:27 +01:00
versions.nix
zip-int-bits.nix