Help with config infinite recursion

Hey all — I’ve having trouble diagnosing what I’ve done wrong in configuring home-manager.
I’d love to know both what I’ve done wrong and how to more easily find the actual issue. Thanks!

I’m by no means a master of the nix language, and have likely made a rookie mistake, but it’s not obvious to me how to debug it either. The --show-trace option isn’t giving me enough info.

I’ve pushed the branch feature/team-manager here for full code (if that helps).

So I have the following helper functions in home.nix:

let
  helpers = rec {
    ...
    defaultPath = name: "${env.baseDir}/defaults}/${name}.nix";
    mePath = name: "${env.meDir}/${name}.nix";
    optCallPackage = package: args: default:
      if builtins.pathExists package
      then pkgs.callPackage package args
      else default;
  };

and I’m calling it as follows:

functionArgs = {
  pkgs = pkgs;
  env = env;
  helpers = helpers;
};
defaultHome = with helpers; optCallPackage (defaultPath "home") functionArgs {};
customHomeArgs = { defaults = defaultHome; } // functionArgs;
customHome = with helpers; optCallPackage (mePath "home") customHomeArgs {};

The defaults/home.nix file or overlaid home.nix file looks like:

{ lib, stdenv, pkgs, env, helpers, ... }:
let
  ...
in
{
  ...
  packages = with pkgs; [...];
}

The output is as follows:

nix-home % nix-shell --run "home-manager switch --show-trace"
error: while evaluating the attribute 'text' of the derivation 'news-info.sh' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'newsEntries' at /nix/store/jaakqrmc4pz36676pwcsj05hrrp91wg4-home-manager-src/modules/default.nix:60:3:
while evaluating anonymous function at /nix/store/jaakqrmc4pz36676pwcsj05hrrp91wg4-home-manager-src/modules/default.nix:62:15, called from undefined position:
while evaluating the attribute 'condition' at undefined position:
while evaluating 'g' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:298:19, called from undefined position:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:140:72, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:301:20:
while evaluating the attribute 'value' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:525:9:
while evaluating the option `news.entries.[definition 1-entry 26].condition':
while evaluating the attribute 'mergedValue' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:557:5:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:551:9:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:650:7:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:537:28, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:537:17:
while evaluating definitions from `/nix/store/jaakqrmc4pz36676pwcsj05hrrp91wg4-home-manager-src/modules/misc/news.nix':
while evaluating 'dischargeProperties' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:609:25, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:538:137:
while evaluating the attribute 'value' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:392:44:
while evaluating the attribute 'home.activation' at undefined position:
while evaluating 'g' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:298:19, called from undefined position:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:140:72, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:301:20:
while evaluating the attribute 'value' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:525:9:
while evaluating the option `home.activation':
while evaluating the attribute 'mergedValue' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:557:5:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:551:9:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:650:7:
while evaluating 'byName' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:364:25, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:391:22:
while evaluating the attribute 'home' at undefined position:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:377:38, called from undefined position:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:387:46, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:378:56:
while evaluating 'pushDownProperties' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:589:24, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:388:69:
while evaluating 'optCallPackage' at /Users/ldeck/tools/nix-home/home.nix:39:37, called from /Users/ldeck/tools/nix-home/home.nix:63:30:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:303:44, called from undefined position:
while evaluating the module argument `pkgs' in "/Users/ldeck/tools/nix-home/home.nix":
while evaluating the attribute '_module.args.pkgs' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:366:7:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/types.nix:410:29, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:366:15:
while evaluating the attribute 'optionalValue.value' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:569:5:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:551:9:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:547:19, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:547:14:
while evaluating the attribute 'value._type' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:648:73:
while evaluating the attribute 'value.content' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:708:14:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:303:44, called from undefined position:
while evaluating the module argument `pkgsPath' in "/nix/store/jaakqrmc4pz36676pwcsj05hrrp91wg4-home-manager-src/modules/misc/nixpkgs.nix":
while evaluating the attribute '_module.args.pkgsPath' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:366:7:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/types.nix:410:29, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:366:15:
while evaluating the attribute 'optionalValue.value' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:569:5:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:551:9:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:547:19, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:547:14:
while evaluating the attribute 'value._type' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:648:73:
while evaluating the attribute 'value.content' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:708:14:
while evaluating 'versionAtLeast' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/strings.nix:503:24, called from /nix/store/jaakqrmc4pz36676pwcsj05hrrp91wg4-home-manager-src/modules/modules.nix:248:12:
while evaluating 'versionOlder' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/strings.nix:491:22, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/strings.nix:503:29:
while evaluating the attribute 'home.stateVersion' at undefined position:
while evaluating 'g' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:298:19, called from undefined position:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:140:72, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:301:20:
while evaluating the attribute 'value' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:525:9:
while evaluating the option `home.stateVersion':
while evaluating the attribute 'mergedValue' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:557:5:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:551:9:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:650:7:
infinite recursion encountered, at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:400:20

@rycee (sorry to ping you) but it looks like I’m hitting a similar issue to Infinite recursion on `if` when reading from `config` · Issue #970 · nix-community/home-manager · GitHub, but I’m not sure how to fix it.

I’ve tried various things without success.

Progress. Looks like my understanding of callPackage needs improving…

So I’ve made progress by just doing an import instead like so:

optCallPackage = package: args: default:
       if builtins.pathExists package
-      then pkgs.callPackage package args
+     then import package args
       else default;

functionArgs = {
     pkgs = pkgs;
+    stdenv = stdenv;
+    lib = lib;
     env = env;
     helpers = helpers;
   };

But now I’m seeing something I didn’t expect.

% nix-shell --run "home-manager switch"
error: attribute 'git' missing, at /Users/ldeck/.me.d/programs.nix:4:9
(use '--show-trace' to show detailed location information)

Any ideas?

My custom ~/.me.d/programs.nix has this:

{ stdenv, env, lib, defaults, pkgs, helpers, ...}:

defaults // {
  git = defaults.git // {
    userName = "Lachlan Deck";
    userEmail = "lachlan.deck@gmail.com";
  };
}

Okay — I’ve got the config working at this commit

Attempting to now re-use callPackage again brings back the infinite recursion however.

So how do I use callPackage properly?

optCallPackage = package: args: default:
      if builtins.pathExists package
      #then import package args
      then pkgs.callPackage package args
      else default;

That gives me this result:

% nix-shell --run "home-manager switch --show-trace"
error: while evaluating the attribute 'text' of the derivation 'news-info.sh' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'newsEntries' at /nix/store/jaakqrmc4pz36676pwcsj05hrrp91wg4-home-manager-src/modules/default.nix:60:3:
while evaluating anonymous function at /nix/store/jaakqrmc4pz36676pwcsj05hrrp91wg4-home-manager-src/modules/default.nix:62:15, called from undefined position:
while evaluating the attribute 'condition' at undefined position:
while evaluating 'g' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:298:19, called from undefined position:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:140:72, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:301:20:
while evaluating the attribute 'value' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:525:9:
while evaluating the option `news.entries.[definition 1-entry 2].condition':
while evaluating the attribute 'mergedValue' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:557:5:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:551:9:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:650:7:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:537:28, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:537:17:
while evaluating definitions from `/nix/store/jaakqrmc4pz36676pwcsj05hrrp91wg4-home-manager-src/modules/misc/news.nix':
while evaluating 'dischargeProperties' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:609:25, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:538:137:
while evaluating the attribute 'value' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:392:44:
while evaluating the attribute 'programs.zsh.enable' at undefined position:
while evaluating 'g' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:298:19, called from undefined position:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:140:72, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:301:20:
while evaluating the attribute 'value' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:525:9:
while evaluating the option `programs.zsh.enable':
while evaluating the attribute 'mergedValue' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:557:5:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:551:9:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:650:7:
while evaluating 'byName' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:364:25, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:391:22:
while evaluating 'byName' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:364:25, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:387:21:
while evaluating the attribute 'programs' at undefined position:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:377:38, called from undefined position:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:387:46, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:378:56:
while evaluating 'pushDownProperties' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:589:24, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:388:69:
while evaluating 'optCallPackage' at /Users/ldeck/tools/nix-home/home.nix:39:37, called from /Users/ldeck/tools/nix-home/home.nix:69:22:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:303:44, called from undefined position:
while evaluating the module argument `pkgs' in "/Users/ldeck/tools/nix-home/home.nix":
while evaluating the attribute '_module.args.pkgs' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:366:7:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/types.nix:410:29, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:366:15:
while evaluating the attribute 'optionalValue.value' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:569:5:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:551:9:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:547:19, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:547:14:
while evaluating the attribute 'value._type' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:648:73:
while evaluating the attribute 'value.content' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:708:14:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:303:44, called from undefined position:
while evaluating the module argument `pkgsPath' in "/nix/store/jaakqrmc4pz36676pwcsj05hrrp91wg4-home-manager-src/modules/misc/nixpkgs.nix":
while evaluating the attribute '_module.args.pkgsPath' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:366:7:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/types.nix:410:29, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:366:15:
while evaluating the attribute 'optionalValue.value' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:569:5:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:551:9:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:547:19, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:547:14:
while evaluating the attribute 'value._type' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:648:73:
while evaluating the attribute 'value.content' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:708:14:
while evaluating 'versionAtLeast' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/strings.nix:503:24, called from /nix/store/jaakqrmc4pz36676pwcsj05hrrp91wg4-home-manager-src/modules/modules.nix:248:12:
while evaluating 'versionOlder' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/strings.nix:491:22, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/strings.nix:503:29:
while evaluating the attribute 'home.stateVersion' at undefined position:
while evaluating 'g' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:298:19, called from undefined position:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:140:72, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:301:20:
while evaluating the attribute 'value' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:525:9:
while evaluating the option `home.stateVersion':
while evaluating the attribute 'mergedValue' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:557:5:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:551:9:
while evaluating the attribute 'values' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:650:7:
while evaluating 'byName' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:364:25, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:391:22:
while evaluating the attribute 'home' at undefined position:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:377:38, called from undefined position:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:387:46, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:378:56:
while evaluating 'pushDownProperties' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:589:24, called from /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:388:69:
while evaluating 'optCallPackage' at /Users/ldeck/tools/nix-home/home.nix:39:37, called from /Users/ldeck/tools/nix-home/home.nix:66:18:
while evaluating anonymous function at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/modules.nix:303:44, called from undefined position:
while evaluating the module argument `pkgs' in "/Users/ldeck/tools/nix-home/home.nix":
while evaluating the attribute '_module.args.pkgs' at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:366:7:
infinite recursion encountered, at /nix/store/cc5ylc3i1h4dsh4a81cz4l6nsk6b5mvg-nixpkgs-unstable-src/lib/attrsets.nix:366:7

I suspect your problem is that callPackage requires the pkgs argument to be evaluated, but options can change the value of pkgs, by adding an overlay, for example, so your definition is self-referential.

Yes, adding an overlay is done through nixpkgs.overlays, not anything under home, but this doesn’t matter, since any option can make its value dependent on any other. Also, you can straight-up alter the value of _module.args.pkgs if you want.

This wouldn’t matter if you were setting an individual option this way, but because you’re setting an entire option group, you have a problem.

Even if you solved that problem somehow, callPackage adds attributes to its result to make it overrideable, which would cause the module system to complain about setting non-existent options.

Moreover, your whole approach here is definitely making things harder than they need to be. Is there any particular reason you can’t just use imports = [ defaultHome customHome ] and so on? You’d need to prefix home. onto the options in those files, but other than that it would work fine, and this is the expected method to split your config into multiple files.