Error: infinite recursion encountered

I have the following nixos module:

{ config, zpool-root, root-domain, unstable, ... }:
let
  domain = "paperless.${root-domain}";
in
{
  config = {
    services = {
      paperless = {
        enable = true;
        address = "127.0.0.1";
        port = 49203;
        package = unstable.paperless-ngx;
        user = config.users.users.main.name;
        passwordFile = config.age.secrets.nas.path;
        domain = domain;
        settings = {
          PAPERLESS_ADMIN_USER = config.users.users.main.name;
          # PAPERLESS_OCR_USER_ARGS = { continue_on_soft_render_error = true; };
        };
        exporter = {
          enable = true;
          directory = "${zpool-root}/paperless";
        };
      };

      traefik.dynamicConfigOptions.http = {
        routers.paperless = {
          rule = "Host(`${domain}`)";
          service = "paperless";
        };

        services.paperless.loadbalancer.servers = [
          {
            url = "http://${config.services.paperless.address}:${builtins.toString config.services.paperless.port}";
          }
        ];
      };
    };
  };
}

But I’m getting the following error message, if I try to rebuild my config (full output with --show-trace):

error:
       … while calling the 'seq' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:361:18:
          360|         options = checked options;
          361|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          362|         _module = checked (config._module);

       … while evaluating the attribute 'unmatchedDefns'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:894:7:
          893|       # Transforms unmatchedDefnsByName into a list of definitions
          894|       unmatchedDefns =
             |       ^
          895|         if configs == [ ] then

       … while calling the 'concatLists' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:900:11:
          899|         else
          900|           concatLists (
             |           ^
          901|             mapAttrsToList (

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:902:21:
          901|             mapAttrsToList (
          902|               name: defs:
             |                     ^
          903|               map (

       … while calling the 'map' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:903:15:
          902|               name: defs:
          903|               map (
             |               ^
          904|                 def:

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:886:22:
          885|         # Propagate all unmatched definitions from nested option sets
          886|         mapAttrs (n: v: v.unmatchedDefns) resultsByName
             |                      ^
          887|         # Plus the definitions for the current prefix that don't have a matching option

       … while evaluating the attribute 'unmatchedDefns'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:894:7:
          893|       # Transforms unmatchedDefnsByName into a list of definitions
          894|       unmatchedDefns =
             |       ^
          895|         if configs == [ ] then

       … while evaluating configs
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:895:12:
          894|       unmatchedDefns =
          895|         if configs == [ ] then
             |            ^
          896|           # When no config values exist, there can be no unmatched config, so

       … while calling the 'concatLists' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:834:47:
          833|           loc = prefix ++ [ name ];
          834|           defns = pushedDownDefinitionsByName.${name} or [ ];
             |                                               ^
          835|           defns' = rawDefinitionsByName.${name} or [ ];

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:791:16:
          790|           mapAttrs (
          791|             n: value:
             |                ^
          792|             map (config: {

       … while calling the 'map' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:792:13:
          791|             n: value:
          792|             map (config: {
             |             ^
          793|               inherit (module) file;

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:795:17:
          794|               inherit config;
          795|             }) (pushDownProperties value)
             |                 ^
          796|           ) module.config

       … while calling 'pushDownProperties'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1282:5:
         1281|   pushDownProperties =
         1282|     cfg:
             |     ^
         1283|     if cfg._type or "" == "merge" then

       … while calling the 'map' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1286:7:
         1285|     else if cfg._type or "" == "if" then
         1286|       map (mapAttrs (n: v: mkIf cfg.condition v)) (pushDownProperties cfg.content)
             |       ^
         1287|     else if cfg._type or "" == "override" then

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1286:52:
         1285|     else if cfg._type or "" == "if" then
         1286|       map (mapAttrs (n: v: mkIf cfg.condition v)) (pushDownProperties cfg.content)
             |                                                    ^
         1287|     else if cfg._type or "" == "override" then

       … while calling 'pushDownProperties'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1282:5:
         1281|   pushDownProperties =
         1282|     cfg:
             |     ^
         1283|     if cfg._type or "" == "merge" then

       … while evaluating an expression to select '_type' on it
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1283:8:
         1282|     cfg:
         1283|     if cfg._type or "" == "merge" then
             |        ^
         1284|       concatMap pushDownProperties cfg.contents

       … while evaluating cfg
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1283:8:
         1282|     cfg:
         1283|     if cfg._type or "" == "merge" then
             |        ^
         1284|       concatMap pushDownProperties cfg.contents

       … while evaluating the attribute 'content'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1471:23:
         1470|     _type = "if";
         1471|     inherit condition content;
             |                       ^
         1472|   };

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/nixos/modules/services/misc/paperless.nix:630:17:
          629|
          630|         users = lib.optionalAttrs (cfg.user == defaultUser) {
             |                 ^
          631|           users.${defaultUser} = {

       … while calling 'optionalAttrs'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1478:25:
         1477|   */
         1478|   optionalAttrs = cond: as: if cond then as else { };
             |                         ^
         1479|

       … while evaluating cond
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1478:32:
         1477|   */
         1478|   optionalAttrs = cond: as: if cond then as else { };
             |                                ^
         1479|

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/nixos/modules/services/misc/paperless.nix:630:40:
          629|
          630|         users = lib.optionalAttrs (cfg.user == defaultUser) {
             |                                        ^
          631|           users.${defaultUser} = {

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1188:17:
         1187|         mapAttrs (
         1188|           name: value:
             |                 ^
         1189|           if isAttrs value && cond value then recurse (path ++ [ name ]) value else f (path ++ [ name ]) value

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1189:85:
         1188|           name: value:
         1189|           if isAttrs value && cond value then recurse (path ++ [ name ]) value else f (path ++ [ name ]) value
             |                                                                                     ^
         1190|         );

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:275:71:
          274|           # For definitions that have an associated option
          275|           declaredConfig = mapAttrsRecursiveCond (v: !isOption v) (_: v: v.value) options;
             |                                                                       ^
          276|

       … while evaluating the attribute 'value'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1118:7:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1118:15:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |               ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `services.paperless.user':

       … while evaluating the attribute 'mergedValue'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1192:5:
         1191|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
         1192|     mergedValue =
             |     ^
         1193|       if isDefined then

       … while evaluating isDefined
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1193:10:
         1192|     mergedValue =
         1193|       if isDefined then
             |          ^
         1194|         if type.merge ? v2 then

       … while evaluating defsFinal
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1254:17:
         1253|
         1254|     isDefined = defsFinal != [ ];
             |                 ^
         1255|

       … while evaluating the attribute 'values'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1186:9:
         1185|       {
         1186|         values = defsSorted;
             |         ^
         1187|         inherit (defsFiltered) highestPrio;

       … while calling the 'any' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1180:14:
         1179|           # Avoid sorting if we don't have to.
         1180|           if any (def: def.value._type or "" == "order") defsFiltered.values then
             |              ^
         1181|             sortProperties defsFiltered.values

       … while evaluating the attribute 'values'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1360:7:
         1359|     {
         1360|       values = concatMap (def: if getPrio def == highestPrio then [ (strip def) ] else [ ]) defs;
             |       ^
         1361|       inherit highestPrio;

       … while calling the 'concatMap' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1360:16:
         1359|     {
         1360|       values = concatMap (def: if getPrio def == highestPrio then [ (strip def) ] else [ ]) defs;
             |                ^
         1361|       inherit highestPrio;

       … while calling the 'concatMap' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1160:26:
         1159|         # Process mkMerge and mkIf properties.
         1160|         defsNormalized = concatMap (
             |                          ^
         1161|           m:

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1161:11:
         1160|         defsNormalized = concatMap (
         1161|           m:
             |           ^
         1162|           map (

       … while calling the 'map' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1162:11:
         1161|           m:
         1162|           map (
             |           ^
         1163|             value:

       … while calling the 'addErrorContext' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1171:14:
         1170|               }
         1171|           ) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |              ^
         1172|         ) defs;

       … while evaluating definitions from `/nix/store/2q7sxnl7jljxyb8r6d7aizldrylxmqy6-source/systems/nas/services/paperless.nix':

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1171:80:
         1170|               }
         1171|           ) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                ^
         1172|         ) defs;

       … while calling 'dischargeProperties'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1311:5:
         1310|   dischargeProperties =
         1311|     def:
             |     ^
         1312|     if def._type or "" == "merge" then

       … while evaluating an expression to select '_type' on it
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1312:8:
         1311|     def:
         1312|     if def._type or "" == "merge" then
             |        ^
         1313|       concatMap dischargeProperties def.contents

       … while evaluating def
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1312:8:
         1311|     def:
         1312|     if def._type or "" == "merge" then
             |        ^
         1313|       concatMap dischargeProperties def.contents

       … while evaluating the attribute 'value'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:805:21:
          804|             inherit (module) file;
          805|             inherit value;
             |                     ^
          806|           }) module.config

       … while evaluating an expression to select 'main' on it
         at /nix/store/2q7sxnl7jljxyb8r6d7aizldrylxmqy6-source/systems/nas/services/paperless.nix:13:35:
           12|         package = unstable.paperless-ngx;
           13|         user = config.users.users.main.name;
             |                                   ^
           14|         passwordFile = config.age.secrets.nas.path;

       … from call site
         at /nix/store/2q7sxnl7jljxyb8r6d7aizldrylxmqy6-source/systems/nas/services/paperless.nix:13:16:
           12|         package = unstable.paperless-ngx;
           13|         user = config.users.users.main.name;
             |                ^
           14|         passwordFile = config.age.secrets.nas.path;

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1188:17:
         1187|         mapAttrs (
         1188|           name: value:
             |                 ^
         1189|           if isAttrs value && cond value then recurse (path ++ [ name ]) value else f (path ++ [ name ]) value

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1189:85:
         1188|           name: value:
         1189|           if isAttrs value && cond value then recurse (path ++ [ name ]) value else f (path ++ [ name ]) value
             |                                                                                     ^
         1190|         );

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:275:71:
          274|           # For definitions that have an associated option
          275|           declaredConfig = mapAttrsRecursiveCond (v: !isOption v) (_: v: v.value) options;
             |                                                                       ^
          276|

       … while evaluating the attribute 'value'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1118:7:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1118:15:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |               ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `users.users':

       (8 duplicate frames omitted)

       … while evaluating defs
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1087:12:
         1086|         })
         1087|         ++ defs;
             |            ^
         1088|

       … while evaluating an expression to select '"${...}"' on it
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:835:20:
          834|           defns = pushedDownDefinitionsByName.${name} or [ ];
          835|           defns' = rawDefinitionsByName.${name} or [ ];
             |                    ^
          836|           optionDecls = filter (

       … while evaluating rawDefinitionsByName
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:835:20:
          834|           defns = pushedDownDefinitionsByName.${name} or [ ];
          835|           defns' = rawDefinitionsByName.${name} or [ ];
             |                    ^
          836|           optionDecls = filter (

       … while calling the 'zipAttrsWith' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:800:30:
          799|       # extract the definitions for each loc
          800|       rawDefinitionsByName = zipAttrsWith (n: v: v) (
             |                              ^
          801|         map (

       … while calling the 'map' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:801:9:
          800|       rawDefinitionsByName = zipAttrsWith (n: v: v) (
          801|         map (
             |         ^
          802|           module:

       … while calling the 'all' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:768:16:
          767|       checkedConfigs =
          768|         assert all (
             |                ^
          769|           c:

       error: infinite recursion encountered

I don’t understand why I’m getting the infinite recursion.
I have this in another module which gets imported:

{...}: {
  config = {
    users = {
      groups = {
        plugdev = { };
      };

      users.main = {
        name = "tornax";
        # ...
      };
    };
  };
}

So config.users.users.main.name shouldn’t require any recursion call?

From the trace, it appears that evaluating users.users somehow requires it to already be evaluated. My suspicion is that you’ve somehow made the attrname or contents of a user entry completely dependent on another user entry. Because of the way attrsOf works, this can cause infinite recursion. (Actually, in the case of the attrname being dependent, this causes infrec even with lazyAttrsOf)

One plausible reason this could happen is if the paperless module expects to create a dedicated user, and is thus trying to create a user with the name you gave it, rather than using the existing one.

1 Like

Thank you for the hints, I’ll try some things out.

Ok, this module works fine:

{ config, zpool-root, root-domain, unstable, ... }:
let
  domain = "paperless.${root-domain}";
in
{
  config = {
    age.secrets.paperless = {
      owner = config.services.paperless.user;
      file = ../../../secrets/paperless.age;
    };

    services = {
      paperless = {
        enable = true;
        address = "127.0.0.1";
        port = 49203;
        package = unstable.paperless-ngx;
        passwordFile = config.age.secrets.paperless.path;
        domain = domain;
        settings = {
          # PAPERLESS_ADMIN_USER = config.users.users.main.name;
          # PAPERLESS_OCR_USER_ARGS = { continue_on_soft_render_error = true; };
        };
        exporter = {
          enable = true;
          directory = "${zpool-root}/paperless";
        };
      };

      traefik.dynamicConfigOptions.http = {
        routers.paperless = {
          rule = "Host(`${domain}`)";
          service = "paperless";
        };

        services.paperless.loadbalancer.servers = [
          {
            url = "http://${config.services.paperless.address}:${builtins.toString config.services.paperless.port}";
          }
        ];
      };
    };
  };
}

but if uncomment this line:

# PAPERLESS_ADMIN_USER = config.users.users.main.name;

then I’m getting this (with --show-trace):

… while evaluating the option `home-manager.users.main.assertions':

       (11 duplicate frames omitted)

       … while evaluating definitions from `/nix/store/p6c56y8hk6smnkggimbiazrvm9jkjb5p-source/modules/systemd.nix':

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1171:80:
         1170|               }
         1171|           ) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                ^
         1172|         ) defs;

       … while calling 'dischargeProperties'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1311:5:
         1310|   dischargeProperties =
         1311|     def:
             |     ^
         1312|     if def._type or "" == "merge" then

       … while calling the 'isBool' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1315:10:
         1314|     else if def._type or "" == "if" then
         1315|       if isBool def.condition then
             |          ^
         1316|         if def.condition then dischargeProperties def.content else [ ]

       … while evaluating the attribute 'condition'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1471:13:
         1470|     _type = "if";
         1471|     inherit condition content;
             |             ^
         1472|   };

       … while evaluating the attribute 'condition'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1471:13:
         1470|     _type = "if";
         1471|     inherit condition content;
             |             ^
         1472|   };

       … from call site
         at /nix/store/p6c56y8hk6smnkggimbiazrvm9jkjb5p-source/modules/systemd.nix:431:44:
          430|   # Do not install any user services if username is root.
          431|   config = mkIf (cfg.enable && config.home.username != "root") {
             |                                            ^
          432|     assertions = [

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1188:17:
         1187|         mapAttrs (
         1188|           name: value:
             |                 ^
         1189|           if isAttrs value && cond value then recurse (path ++ [ name ]) value else f (path ++ [ name ]) value

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1189:85:
         1188|           name: value:
         1189|           if isAttrs value && cond value then recurse (path ++ [ name ]) value else f (path ++ [ name ]) value
             |                                                                                     ^
         1190|         );

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:275:71:
          274|           # For definitions that have an associated option
          275|           declaredConfig = mapAttrsRecursiveCond (v: !isOption v) (_: v: v.value) options;
             |                                                                       ^
          276|

       … while evaluating the attribute 'value'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1118:7:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1118:15:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |               ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `home-manager.users.main.home.username':

       (11 duplicate frames omitted)

       … while evaluating definitions from `/nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/flake.nix':

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1171:80:
         1170|               }
         1171|           ) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                ^
         1172|         ) defs;

       … while calling 'dischargeProperties'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1311:5:
         1310|   dischargeProperties =
         1311|     def:
             |     ^
         1312|     if def._type or "" == "merge" then

       … while evaluating an expression to select '_type' on it
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1312:8:
         1311|     def:
         1312|     if def._type or "" == "merge" then
             |        ^
         1313|       concatMap dischargeProperties def.contents

       … while evaluating def
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1312:8:
         1311|     def:
         1312|     if def._type or "" == "merge" then
             |        ^
         1313|       concatMap dischargeProperties def.contents

       … while evaluating the attribute 'value'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:805:21:
          804|             inherit (module) file;
          805|             inherit value;
             |                     ^
          806|           }) module.config

       … while evaluating an expression to select 'main' on it
         at /nix/store/aijgph6csql8sb33xpjm5hhg2mrd429l-source/modules/home-manager/default.nix:40:41:
           39|         home = {
           40|           username = config.users.users.main.name;
             |                                         ^
           41|           homeDirectory = "/home/${config.users.users.main.name}";

       … from call site
         at /nix/store/aijgph6csql8sb33xpjm5hhg2mrd429l-source/modules/home-manager/default.nix:40:22:
           39|         home = {
           40|           username = config.users.users.main.name;
             |                      ^
           41|           homeDirectory = "/home/${config.users.users.main.name}";

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1188:17:
         1187|         mapAttrs (
         1188|           name: value:
             |                 ^
         1189|           if isAttrs value && cond value then recurse (path ++ [ name ]) value else f (path ++ [ name ]) value

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1189:85:
         1188|           name: value:
         1189|           if isAttrs value && cond value then recurse (path ++ [ name ]) value else f (path ++ [ name ]) value
             |                                                                                     ^
         1190|         );

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:275:71:
          274|           # For definitions that have an associated option
          275|           declaredConfig = mapAttrsRecursiveCond (v: !isOption v) (_: v: v.value) options;
             |                                                                       ^
          276|

       … while evaluating the attribute 'value'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1118:7:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1118:15:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |               ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `users.users':

       (11 duplicate frames omitted)

       … while evaluating definitions from `/nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/nixos/modules/services/databases/redis.nix':

       (6 duplicate frames omitted)

       … while evaluating enabledServers
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/nixos/modules/services/databases/redis.nix:453:22:
          452|
          453|   config = lib.mkIf (enabledServers != { }) {
             |                      ^
          454|

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/nixos/modules/services/databases/redis.nix:29:20:
           28|   redisName = name: "redis" + lib.optionalString (name != "") ("-" + name);
           29|   enabledServers = lib.filterAttrs (name: conf: conf.enable) config.services.redis.servers;
             |                    ^
           30|

       … while calling 'filterAttrs'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:663:23:
          662|   */
          663|   filterAttrs = pred: set: removeAttrs set (filter (name: !pred name set.${name}) (attrNames set));
             |                       ^
          664|

       … while calling the 'removeAttrs' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:663:28:
          662|   */
          663|   filterAttrs = pred: set: removeAttrs set (filter (name: !pred name set.${name}) (attrNames set));
             |                            ^
          664|

       … while calling the 'filter' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:663:45:
          662|   */
          663|   filterAttrs = pred: set: removeAttrs set (filter (name: !pred name set.${name}) (attrNames set));
             |                                             ^
          664|

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:663:53:
          662|   */
          663|   filterAttrs = pred: set: removeAttrs set (filter (name: !pred name set.${name}) (attrNames set));
             |                                                     ^
          664|

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:663:60:
          662|   */
          663|   filterAttrs = pred: set: removeAttrs set (filter (name: !pred name set.${name}) (attrNames set));
             |                                                            ^
          664|

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/nixos/modules/services/databases/redis.nix:29:43:
           28|   redisName = name: "redis" + lib.optionalString (name != "") ("-" + name);
           29|   enabledServers = lib.filterAttrs (name: conf: conf.enable) config.services.redis.servers;
             |                                           ^
           30|

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/nixos/modules/services/databases/redis.nix:29:54:
           28|   redisName = name: "redis" + lib.optionalString (name != "") ("-" + name);
           29|   enabledServers = lib.filterAttrs (name: conf: conf.enable) config.services.redis.servers;
             |                                                      ^
           30|

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1188:17:
         1187|         mapAttrs (
         1188|           name: value:
             |                 ^
         1189|           if isAttrs value && cond value then recurse (path ++ [ name ]) value else f (path ++ [ name ]) value

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1189:85:
         1188|           name: value:
         1189|           if isAttrs value && cond value then recurse (path ++ [ name ]) value else f (path ++ [ name ]) value
             |                                                                                     ^
         1190|         );

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:275:71:
          274|           # For definitions that have an associated option
          275|           declaredConfig = mapAttrsRecursiveCond (v: !isOption v) (_: v: v.value) options;
             |                                                                       ^
          276|

       … while evaluating the attribute 'value'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1118:7:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1118:15:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |               ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `services.redis.servers.paperless.enable':

       (11 duplicate frames omitted)

       … while evaluating definitions from `/nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/nixos/modules/services/misc/paperless.nix':

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1171:80:
         1170|               }
         1171|           ) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                ^
         1172|         ) defs;

       … while calling 'dischargeProperties'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1311:5:
         1310|   dischargeProperties =
         1311|     def:
             |     ^
         1312|     if def._type or "" == "merge" then

       … while calling the 'isBool' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1315:10:
         1314|     else if def._type or "" == "if" then
         1315|       if isBool def.condition then
             |          ^
         1316|         if def.condition then dischargeProperties def.content else [ ]

       … while evaluating the attribute 'condition'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1471:13:
         1470|     _type = "if";
         1471|     inherit condition content;
             |             ^
         1472|   };

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/nixos/modules/services/misc/paperless.nix:16:23:
           15|   # Don't start a redis instance if the user sets a custom redis connection
           16|   enableRedis = !(cfg.settings ? PAPERLESS_REDIS);
             |                       ^
           17|   redisServer = config.services.redis.servers.paperless;

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1188:17:
         1187|         mapAttrs (
         1188|           name: value:
             |                 ^
         1189|           if isAttrs value && cond value then recurse (path ++ [ name ]) value else f (path ++ [ name ]) value

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1189:85:
         1188|           name: value:
         1189|           if isAttrs value && cond value then recurse (path ++ [ name ]) value else f (path ++ [ name ]) value
             |                                                                                     ^
         1190|         );

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:275:71:
          274|           # For definitions that have an associated option
          275|           declaredConfig = mapAttrsRecursiveCond (v: !isOption v) (_: v: v.value) options;
             |                                                                       ^
          276|

       … while evaluating the attribute 'value'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1118:7:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1118:15:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |               ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `services.paperless.settings':

       … while evaluating the attribute 'mergedValue'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1192:5:
         1191|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
         1192|     mergedValue =
             |     ^
         1193|       if isDefined then

       … while evaluating the attribute 'value'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/types.nix:1307:17:
         1306|                 headError = checkDefsForError check loc defs;
         1307|                 value = configuration.config;
             |                 ^
         1308|                 valueMeta = { inherit configuration; };

       … while evaluating the attribute 'config'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:361:9:
          360|         options = checked options;
          361|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          362|         _module = checked (config._module);

       … while calling the 'seq' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:361:18:
          360|         options = checked options;
          361|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          362|         _module = checked (config._module);

       … while evaluating an expression to select '_module.check' on it
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:297:12:
          296|       checkUnmatched =
          297|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [ ] then
             |            ^
          298|           let

       … while evaluating config
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:297:12:
          296|       checkUnmatched =
          297|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [ ] then
             |            ^
          298|           let

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:294:11:
          293|         else
          294|           recursiveUpdate freeformConfig declaredConfig;
             |           ^
          295|

       … while calling 'recursiveUpdate'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1746:10:
         1745|   recursiveUpdate =
         1746|     lhs: rhs:
             |          ^
         1747|     recursiveUpdateUntil (

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1747:5:
         1746|     lhs: rhs:
         1747|     recursiveUpdateUntil (
             |     ^
         1748|       path: lhs: rhs:

       … while calling 'recursiveUpdateUntil'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1686:16:
         1685|   recursiveUpdateUntil =
         1686|     pred: lhs: rhs:
             |                ^
         1687|     let

       … while calling the 'zipAttrsWith' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:1701:5:
         1700|     in
         1701|     f [ ] [ rhs lhs ];
             |     ^
         1702|

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:285:42:
          284|             in
          285|             if defs == [ ] then { } else declaredConfig._module.freeformType.merge prefix defs;
             |                                          ^
          286|

       … while calling '__functor'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/types.nix:861:26:
          860|             __functor =
          861|               self: loc: defs:
             |                          ^
          862|               (self.v2 { inherit loc defs; }).value;

       … while evaluating the attribute 'value'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/types.nix:878:17:
          877|                 headError = checkDefsForError check loc defs;
          878|                 value = mapAttrs (
             |                 ^
          879|                   n: v:

       … while calling the 'mapAttrs' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/types.nix:878:25:
          877|                 headError = checkDefsForError check loc defs;
          878|                 value = mapAttrs (
             |                         ^
          879|                   n: v:

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/types.nix:872:21:
          871|                     # Meaning it is less lazy
          872|                     filterAttrs (n: v: v.optionalValue ? value) (
             |                     ^
          873|                       zipAttrsWith (name: defs: mergeDefinitions (loc ++ [ name ]) elemType defs) (pushPositions defs)

       … while calling 'filterAttrs'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:663:23:
          662|   */
          663|   filterAttrs = pred: set: removeAttrs set (filter (name: !pred name set.${name}) (attrNames set));
             |                       ^
          664|

       … while calling the 'removeAttrs' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:663:28:
          662|   */
          663|   filterAttrs = pred: set: removeAttrs set (filter (name: !pred name set.${name}) (attrNames set));
             |                            ^
          664|

       … while calling the 'filter' builtin
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:663:45:
          662|   */
          663|   filterAttrs = pred: set: removeAttrs set (filter (name: !pred name set.${name}) (attrNames set));
             |                                             ^
          664|

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:663:53:
          662|   */
          663|   filterAttrs = pred: set: removeAttrs set (filter (name: !pred name set.${name}) (attrNames set));
             |                                                     ^
          664|

       … from call site
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/attrsets.nix:663:60:
          662|   */
          663|   filterAttrs = pred: set: removeAttrs set (filter (name: !pred name set.${name}) (attrNames set));
             |                                                            ^
          664|

       … while calling anonymous lambda
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/types.nix:872:37:
          871|                     # Meaning it is less lazy
          872|                     filterAttrs (n: v: v.optionalValue ? value) (
             |                                     ^
          873|                       zipAttrsWith (name: defs: mergeDefinitions (loc ++ [ name ]) elemType defs) (pushPositions defs)

       … while evaluating the attribute 'optionalValue'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1256:5:
         1255|
         1256|     optionalValue = if isDefined then { value = mergedValue; } else { };
             |     ^
         1257|   };

        # ...

       … while evaluating an expression to select 'main' on it
         at /nix/store/aijgph6csql8sb33xpjm5hhg2mrd429l-source/systems/nas/services/paperless.nix:21:53:
           20|         settings = {
           21|           PAPERLESS_ADMIN_USER = config.users.users.main.name;
             |                                                     ^
           22|           # PAPERLESS_OCR_USER_ARGS = { continue_on_soft_render_error = true; };

       … from call site
         at /nix/store/aijgph6csql8sb33xpjm5hhg2mrd429l-source/systems/nas/services/paperless.nix:21:34:
           20|         settings = {
           21|           PAPERLESS_ADMIN_USER = config.users.users.main.name;
             |                                  ^
           22|           # PAPERLESS_OCR_USER_ARGS = { continue_on_soft_render_error = true; };

         # ...
       … while evaluating the attribute 'value'
         at /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source/lib/modules.nix:1118:7:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1119|       inherit (res.defsFinal') highestPrio;

       error: infinite recursion encountered

The error message is on the uncommented line, so you didn’t save your work, or you have it defined in multiple places or something.

Asking here is fine but you do have to read the errors produced.

The error message is on the uncommented line, so you didn’t save your work, or you have it defined in multiple places or something.

Sorry, mistake from my side… I meant uncomment not comment out… ._.
but maybe you’re also right. I don’t know when, but I did a :wa on my editor and some errors changed before… sorry for the noise. I’ll come back if I’m more concentrated and still haven’t fixed the issue.