Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Infinite recursion encountered #83

Closed
gilice opened this issue Dec 13, 2022 · 6 comments
Closed

Error: Infinite recursion encountered #83

gilice opened this issue Dec 13, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@gilice
Copy link

gilice commented Dec 13, 2022

Plugin affected: nixvim home-manager module
Nixpkgs channel: unstable
Home-manager version: (if applicable)
Nixvim version: db8a2c0

Description

Even a simple import will cause the following stack trace:

error: infinite recursion encountered

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:478:28:

          477|         builtins.addErrorContext (context name)
          478|           (args.${name} or config._module.args.${name})
             |                            ^
          479|       ) (lib.functionArgs f);while evaluating the module argument `nixvim' in "/nix/store/2x17848qwkzd5rqf1gl78g0x2hrkiz7l-source/vim.nix":

       … while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:476:44:

          475|       context = name: ''while evaluating the module argument `${name}' in "${key}":'';
          476|       extraArgs = builtins.mapAttrs (name: _:
             |                                            ^
          477|         builtins.addErrorContext (context name)from call sitewhile calling 'isFunction'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/trivial.nix:448:16:

          447|   */
          448|   isFunction = f: builtins.isFunction f ||
             |                ^
          449|     (f ? __functor && isFunction (f.__functor f));from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:355:12:

          354|       loadModule = args: fallbackFile: fallbackKey: m:
          355|         if isFunction m || isAttrs m then
             |            ^
          356|           unifyModuleSyntax fallbackFile fallbackKey (applyModuleArgsIfFunction fallbackKey m args)while calling 'loadModule'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:354:53:

          353|       # Like unifyModuleSyntax, but also imports paths and calls functions if necessary
          354|       loadModule = args: fallbackFile: fallbackKey: m:
             |                                                     ^
          355|         if isFunction m || isAttrs m then

       … from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:395:22:

          394|           let
          395|             module = loadModule args parentFile "${parentKey}:anon-${toString n}" x;
             |                      ^
          396|             collectedImports = collectStructuredModules module._file module.key module.imports args;while evaluating the attribute 'disabled'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:390:13:

          389|           collectResults = modules: {
          390|             disabled = concatLists (catAttrs "disabled" modules);
             |             ^
          391|             inherit modules;while evaluating the attribute 'disabled'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:390:13:

          389|           collectResults = modules: {
          390|             disabled = concatLists (catAttrs "disabled" modules);
             |             ^
          391|             inherit modules;while evaluating the attribute 'disabled'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:390:13:

          389|           collectResults = modules: {
          390|             disabled = concatLists (catAttrs "disabled" modules);
             |             ^
          391|             inherit modules;while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:414:31:

          413|           disabledKeys = map moduleKey disabled;
          414|           keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
             |                               ^
          415|         in map (attrs: attrs.module) (builtins.genericClosure {from call sitewhile calling 'filterModules'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:408:36:

          407|       # modules recursively. It returns the final list of unique-by-key modules
          408|       filterModules = modulesPath: { disabled, modules }:
             |                                    ^
          409|         letfrom call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:421:7:

          420|     in modulesPath: initialModules: args:
          421|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
             |       ^
          422|

       … while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:420:37:

          419|
          420|     in modulesPath: initialModules: args:
             |                                     ^
          421|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:253:25:

          252|       merged =
          253|         let collected = collectModules
             |                         ^
          254|           (specialArgs.modulesPath or "")while calling 'reverseList'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:394:17:

          393|   */
          394|   reverseList = xs:
             |                 ^
          395|     let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:257:33:

          256|           ({ inherit lib options config specialArgs; } // specialArgs);
          257|         in mergeModules prefix (reverseList collected);
             |                                 ^
          258|

       … while calling 'byName'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:537:25:

          536|       */
          537|       byName = attr: f: modules:
             |                         ^
          538|         zipAttrsWith (n: concatLists)from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:554:21:

          553|       # an attrset 'name' => list of submodules that declare ‘name’.
          554|       declsByName = byName "options" (module: option:
             |                     ^
          555|           [{ inherit (module) _file; options = option; }]while evaluating the attribute 'matchedOptions'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:632:14:

          631|     in {
          632|       inherit matchedOptions;
             |              ^
          633|

       … while calling 'mapAttrsRecursiveCond'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:524:5:

          523|     # Attribute set to recursively map over.
          524|     set:
             |     ^
          525|     letfrom call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:265:28:

          264|           # For definitions that have an associated option
          265|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                            ^
          266|

       … while evaluating the attribute 'config'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:341:9:

          340|         options = checked options;
          341|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          342|         _module = checked (config._module);while calling 'merge'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/types.nix:742:22:

          741|         check = x: isAttrs x || isFunction x || path.check x;
          742|         merge = loc: defs:
             |                      ^
          743|           (base.extendModules {from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:760:59:

          759|       if isDefined then
          760|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |                                                           ^
          761|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;while evaluating the attribute 'value'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:771:27:

          770|     optionalValue =
          771|       if isDefined then { value = mergedValue; }
             |                           ^
          772|       else {};while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/types.nix:522:22:

          521|       merge = loc: defs:
          522|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                      ^
          523|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValuefrom call sitewhile calling 'flip'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/trivial.nix:138:16:

          137|   */
          138|   flip = f: a: b: f b a;
             |                ^
          139|

       … from call site

       at /nix/store/3ykv6iilczdsz2830r5dn0wjcs87nm9v-source/nixos/common.nix:104:7:

          103|     assertions = flatten (flip mapAttrsToList cfg.users (user: config:
          104|       flip map config.assertions (assertion: {
             |       ^
          105|         inherit (assertion) assertion;while calling anonymous lambda

       at /nix/store/3ykv6iilczdsz2830r5dn0wjcs87nm9v-source/nixos/common.nix:103:64:

          102|
          103|     assertions = flatten (flip mapAttrsToList cfg.users (user: config:
             |                                                                ^
          104|       flip map config.assertions (assertion: {from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:478:16:

          477|     attrs:
          478|     map (name: f name attrs.${name}) (attrNames attrs);
             |                ^
          479|

       … while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:478:10:

          477|     attrs:
          478|     map (name: f name attrs.${name}) (attrNames attrs);
             |          ^
          479|

       … from call sitewhile calling 'flatten'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:138:13:

          137|   */
          138|   flatten = x:
             |             ^
          139|     if isList xfrom call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:140:24:

          139|     if isList x
          140|     then concatMap (y: flatten y) x
             |                        ^
          141|     else [x];while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:140:21:

          139|     if isList x
          140|     then concatMap (y: flatten y) x
             |                     ^
          141|     else [x];from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:140:10:

          139|     if isList x
          140|     then concatMap (y: flatten y) x
             |          ^
          141|     else [x];while calling 'flatten'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:138:13:

          137|   */
          138|   flatten = x:
             |             ^
          139|     if isList xfrom call site

       at /nix/store/3ykv6iilczdsz2830r5dn0wjcs87nm9v-source/nixos/common.nix:103:18:

          102|
          103|     assertions = flatten (flip mapAttrsToList cfg.users (user: config:
             |                  ^
          104|       flip map config.assertions (assertion: {while evaluating the attribute 'content'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:881:14:

          880|     { _type = "if";
          881|       inherit condition content;
             |              ^
          882|     };while calling 'dischargeProperties'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:810:25:

          809|   */
          810|   dischargeProperties = def:
             |                         ^
          811|     if def._type or "" == "merge" then

       … from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:816:11:

          815|         if def.condition then
          816|           dischargeProperties def.content
             |           ^
          817|         elsewhile calling 'dischargeProperties'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:810:25:

          809|   */
          810|   dischargeProperties = def:
             |                         ^
          811|     if def._type or "" == "merge" then

       … from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:739:137:

          738|         defs' = concatMap (m:
          739|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          740|         ) defs;while evaluating definitions from `/nix/store/3ykv6iilczdsz2830r5dn0wjcs87nm9v-source/nixos/common.nix':

       … while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:738:28:

          737|         # Process mkMerge and mkIf properties.
          738|         defs' = concatMap (m:
             |                            ^
          739|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:738:17:

          737|         # Process mkMerge and mkIf properties.
          738|         defs' = concatMap (m:
             |                 ^
          739|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))while evaluating the attribute 'values'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:851:7:

          850|     in {
          851|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          852|       inherit highestPrio;while evaluating the attribute 'values'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:752:9:

          751|       in {
          752|         values = defs''';
             |         ^
          753|         inherit (defs'') highestPrio;while evaluating the attribute 'mergedValue'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:758:5:

          757|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          758|     mergedValue =
             |     ^
          759|       if isDefined thenwhile evaluating the option `assertions':

       … while evaluating the attribute 'value'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:723:9:

          722|     in warnDeprecation opt //
          723|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          724|         inherit (res.defsFinal') highestPrio;while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:265:72:

          264|           # For definitions that have an associated option
          265|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          266|

       … from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:532:20:

          531|               then recurse (path ++ [name]) value
          532|               else f (path ++ [name]) value;
             |                    ^
          533|         in mapAttrs g;while calling 'g'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:529:19:

          528|           g =
          529|             name: value:
             |                   ^
          530|             if isAttrs value && cond valuefrom call sitewhile calling 'fold''

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:56:15:

           55|       len = length list;
           56|       fold' = n:
             |               ^
           57|         if n == lenfrom call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:60:8:

           59|         else op (elemAt list n) (fold' (n + 1));
           60|     in fold' 0;
             |        ^
           61|

       … while calling 'foldr'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:53:20:

           52|   */
           53|   foldr = op: nul: list:
             |                    ^
           54|     letfrom call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/nixos/modules/system/activation/top-level.nix:123:12:

          122|   # Replace runtime dependencies
          123|   system = foldr ({ oldDependency, newDependency }: drv:
             |            ^
          124|       pkgs.replaceDependency { inherit oldDependency newDependency drv; }while evaluating the attribute 'value'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:563:44:

          562|       defnsByName' = byName "config" (module: value:
          563|           [{ inherit (module) file; inherit value; }]
             |                                            ^
          564|         ) configs;while calling 'dischargeProperties'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:810:25:

          809|   */
          810|   dischargeProperties = def:
             |                         ^
          811|     if def._type or "" == "merge" thenfrom call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:739:137:

          738|         defs' = concatMap (m:
          739|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          740|         ) defs;while evaluating definitions from `/nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/nixos/modules/system/activation/top-level.nix':

       … while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:738:28:

          737|         # Process mkMerge and mkIf properties.
          738|         defs' = concatMap (m:
             |                            ^
          739|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:738:17:

          737|         # Process mkMerge and mkIf properties.
          738|         defs' = concatMap (m:
             |                 ^
          739|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))while evaluating the attribute 'values'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:851:7:

          850|     in {
          851|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          852|       inherit highestPrio;while evaluating the attribute 'values'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:752:9:

          751|       in {
          752|         values = defs''';
             |         ^
          753|         inherit (defs'') highestPrio;while evaluating the attribute 'mergedValue'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:758:5:

          757|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          758|     mergedValue =
             |     ^
          759|       if isDefined thenwhile evaluating the option `system.build.toplevel':

       … while evaluating the attribute 'value'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:723:9:

          722|     in warnDeprecation opt //
          723|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          724|         inherit (res.defsFinal') highestPrio;while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:265:72:

          264|           # For definitions that have an associated option
          265|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          266|

       … from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:532:20:

          531|               then recurse (path ++ [name]) value
          532|               else f (path ++ [name]) value;
             |                    ^
          533|         in mapAttrs g;while calling 'g'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:529:19:

          528|           g =
          529|             name: value:
             |                   ^
          530|             if isAttrs value && cond valuefrom call sitewhile calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:710:24:

          709|     let f = attrPath:
          710|       zipAttrsWith (n: values:
             |                        ^
          711|         let here = attrPath ++ [n]; infrom call site

Config

Your nixvim config

{pkgs, lib, nixvim, ...}: {home-manager.users.usr1 = {
   imports = [
      nixvim.homeManagerModules.nixvim
   ];
};
@gilice gilice added the bug Something isn't working label Dec 13, 2022
@pta2002
Copy link
Collaborator

pta2002 commented Dec 13, 2022

I think this might be related to #66... Have you tried just setting plugins.nixvim.enable = true?

@gilice gilice closed this as completed Dec 19, 2022
@gilice
Copy link
Author

gilice commented Dec 19, 2022

was not related to nixvim but some weird behaviour of home-manager itself

@gador
Copy link
Contributor

gador commented Dec 20, 2022

@gilice did you figure out what exactly caused the error?

@gilice
Copy link
Author

gilice commented Dec 21, 2022

@gador take this with two packets of salt because I didn't care enough to reproduce it.

What seemed to be happening was that if I add a home-manager module at a top-level, eg,

home-manager.users.user1 = {
  imports = [nixvim.homeManagerModules.nixvim];
};

it seems to work. However, if I put it somewhere in a file that is imported, adding one level of nesting:

configuration.nix

home-manager.users.user1 = {
  imports = [
    ./editr-config.nix
  ];
};

and then in

editr-config.nix

{pkgs, lib}: {
   imports = [nixvim.homeManagerModules.nixvim];
}

it throws the error message.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/cannot-get-nixvim-to-install-as-a-module-in-home-manager/49643/2

@eclairevoyant
Copy link

eclairevoyant commented Jul 26, 2024

However, if I put it somewhere in a file that is imported

It's because you didn't pass the top-level input into the module system via extraSpecialArgs; nixvim needs to come from somewhere, and you didn't provide it.

Only pkgs, lib, config, options, etc come for free, your custom args need to be provided explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants