Help with NUR Emacs-init with Flake

Hey guys, I’m trying to import the NUR Emacs-init Home-manager module but I keep getting infinite recursion issues

I imported NUR as an overlay (I’m currently using some NUR packages specifically for downloading Firefox extensions) but this doesn’t seem to be working with NUR modules. Any advice to properly setup the module?

Flake.nix:

Overlay:

Emacs.nix

{ config, lib, pkgs, nur, ... }:
let
  pack = if (config.variables.desktop.displayManager == "wayland") then
    pkgs.emacs29-pgtk
  else
    pkgs.emacs29;
in {
  imports = [ nur.repos.rycee.hmModules.emacs-init ];

  services.emacs = {
    enable = true;
    defaultEditor = true;
    startWithUserSession = "graphical";
    client = {
      enable = true;
      #arguments = [ ];
    };
  };

  programs = {
    pyenv.enable = true;
    emacs = {
      enable = true;
      package = pack;
      extraPackages = epkgs: with epkgs; [ tramp pdf-tools vterm ];
    };
  };

The error

$ nix-shell --run "home-manager switch --flake $FLAKE --show-trace"
error:
       … from call site

         at /nix/store/c1kciy1zip6av31s6bi0bn3l6lz8j4wj-source/modules/default.nix:44:18:

           43|   withExtraAttrs = rawModule:
           44|     let module = moduleChecks rawModule;
             |                  ^
           45|     in {

       … while calling 'moduleChecks'

         at /nix/store/c1kciy1zip6av31s6bi0bn3l6lz8j4wj-source/modules/default.nix:31:18:

           30|
           31|   moduleChecks = raw:
             |                  ^
           32|     showWarnings (let

       … from call site

         at /nix/store/c1kciy1zip6av31s6bi0bn3l6lz8j4wj-source/modules/default.nix:32:5:

           31|   moduleChecks = raw:
           32|     showWarnings (let
             |     ^
           33|       failed = collectFailed raw.config;

       … while calling 'showWarnings'

         at /nix/store/c1kciy1zip6av31s6bi0bn3l6lz8j4wj-source/modules/default.nix:15:18:

           14|
           15|   showWarnings = res:
             |                  ^
           16|     let f = w: x: builtins.trace "warning: ${w}" x;

       … from call site

         at /nix/store/c1kciy1zip6av31s6bi0bn3l6lz8j4wj-source/modules/default.nix:17:8:

           16|     let f = w: x: builtins.trace "warning: ${w}" x;
           17|     in fold f res res.config.warnings;
             |        ^
           18|

       … while calling 'foldr'

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/lists.nix:121:20:

          120|   */
          121|   foldr = op: nul: list:
             |                    ^
          122|     let

       … from call site

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/lists.nix:128:8:

          127|         else op (elemAt list n) (fold' (n + 1));
          128|     in fold' 0;
             |        ^
          129|

       … while calling 'fold''

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/lists.nix:124:15:

          123|       len = length list;
          124|       fold' = n:
             |               ^
          125|         if n == len

       … from call site

         at /nix/store/c1kciy1zip6av31s6bi0bn3l6lz8j4wj-source/modules/default.nix:33:16:

           32|     showWarnings (let
           33|       failed = collectFailed raw.config;
             |                ^
           34|       failedStr = concatStringsSep "\n" (map (x: "- ${x}") failed);

       … while calling 'collectFailed'

         at /nix/store/c1kciy1zip6av31s6bi0bn3l6lz8j4wj-source/modules/default.nix:12:19:

           11|
           12|   collectFailed = cfg:
             |                   ^
           13|     map (x: x.message) (filter (x: !x.assertion) cfg.assertions);

       … from call site

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:242:28:

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

       … while calling 'mapAttrsRecursiveCond'

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/attrsets.nix:1167:5:

         1166|     f:
         1167|     set:
             |     ^
         1168|     let

       … from call site

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:234:33:

          233|           ({ inherit lib options config specialArgs; } // specialArgs);
          234|         in mergeModules prefix (reverseList collected);
             |                                 ^
          235|

       … while calling 'reverseList'

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/lists.nix:1068:17:

         1067|   */
         1068|   reverseList = xs:
             |                 ^
         1069|     let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;

       … from call site

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:229:25:

          228|       merged =
          229|         let collected = collectModules
             |                         ^
          230|           class

       … while calling anonymous lambda

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:445:37:

          444|
          445|     in modulesPath: initialModules: args:
             |                                     ^
          446|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);

       … from call site

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:446:7:

          445|     in modulesPath: initialModules: args:
          446|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
             |       ^
          447|

       … while calling 'filterModules'

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:413:36:

          412|       # modules recursively. It returns the final list of unique-by-key modules
          413|       filterModules = modulesPath: { disabled, modules }:
             |                                    ^
          414|         let

       … while calling anonymous lambda

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:439:31:

          438|           disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
          439|           keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
             |                               ^
          440|         in map (attrs: attrs.module) (builtins.genericClosure {

       … from call site

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:400:22:

          399|           let
          400|             module = checkModule (loadModule args parentFile "${parentKey}:anon-${toString n}" x);
             |                      ^
          401|             collectedImports = collectStructuredModules module._file module.key module.imports args;

       … while calling anonymous lambda

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:365:11:

          364|         else
          365|           m: m;
             |           ^
          366|

       … from call site

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:400:35:

          399|           let
          400|             module = checkModule (loadModule args parentFile "${parentKey}:anon-${toString n}" x);
             |                                   ^
          401|             collectedImports = collectStructuredModules module._file module.key module.imports args;

       … while calling 'loadModule'

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:336:53:

          335|       # Like unifyModuleSyntax, but also imports paths and calls functions if necessary
          336|       loadModule = args: fallbackFile: fallbackKey: m:
             |                                                     ^
          337|         if isFunction m then

       … from call site

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:337:12:

          336|       loadModule = args: fallbackFile: fallbackKey: m:
          337|         if isFunction m then
             |            ^
          338|           unifyModuleSyntax fallbackFile fallbackKey (applyModuleArgs fallbackKey m args)

       … while calling 'isFunction'

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/trivial.nix:929:16:

          928|   */
          929|   isFunction = f: builtins.isFunction f ||
             |                ^
          930|     (f ? __functor && isFunction (f.__functor f));

       … while calling anonymous lambda

         at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:506:44:

          505|       context = name: ''while evaluating the module argument `${name}' in "${key}":'';
          506|       extraArgs = builtins.mapAttrs (name: _:
             |                                            ^
          507|         builtins.addErrorContext (context name)

       … while evaluating the module argument `nur' in "/nix/store/dsa1bc6gzhdwkw16sgaf0chz03m1s681-source/home/novaviper/features/emacs":

       error: infinite recursion encountered

       at /nix/store/panhvrac6ra4wpj9hrg19v4gn189hrqw-source/lib/modules.nix:508:28:

          507|         builtins.addErrorContext (context name)
          508|           (args.${name} or config._module.args.${name})
             |                            ^
          509|       ) (lib.functionArgs f);

I use it in my GitHub - bbigras/nix-config: My personal nix config .

maybe try this. I’m not sure where I picked that up.

nurNoPkgs = import nur { pkgs = null; nurpkgs = pkgs; };
imports = [ nurNoPkgs.repos.rycee.hmModules.emacs-init ];

for the overlay I just used nur.overlay.

Hey I put that in like this in my emacx.nix file, but I still get that infinite recursion error

{
  config,
  lib,
  pkgs,
  nur,
  ...
}: let
  pack =
    if (config.variables.desktop.displayManager == "wayland")
    then pkgs.emacs29-pgtk
    else pkgs.emacs29;
  nurNoPkgs = import nur { pkgs = null; nurpkgs = pkgs; };
in {
imports = [ nurNoPkgs.repos.rycee.hmModules.emacs-init ];

  services.emacs = {
    enable = true;
    defaultEditor = true;
    startWithUserSession = "graphical";
    client = {
      enable = true;
      #arguments = [ ];
    };
  };

  programs = {
    pyenv.enable = true;
    emacs = {
      enable = true;
      package = pack;
      extraPackages = epkgs: with epkgs; [tramp pdf-tools vterm];
    };
  };

And the overlay I have the same thing declared in my overlay.nix file (which my OP shows)

Quick edit: I completely forgot to paste how the overlay.nix file is set for nixpkgs! :sweat:

HomeManager:

NixOS: