Infinite recursion error when using stdenv

I tried to install the feather font using this
And it throws an infinite recursion error anytime I try to rebuild the system for some reason.
I have copied the contents of the above gist into a file in the /etc/nixos/modules/fonts folder called feather-font.nix and am including it in my home.nix.
The error seems to be originating from including stdenv, as this line suggests:

… while evaluating the module argument `stdenv’ in “/nix/store/5rgr39d2s9171l1g7abpwi3njnwk808f-home-manager/fonts/feather-font.nix”: error: infinite recursion encountered

As I am still quite new to NixOS any help would be highly appreciated!

Here is the console log:

/etc/nixos/modules/home-manager/fonts » update-nocache --fast --flake /etc/nixos/#default --show-trace
building the system configuration...
warning: Git tree '/etc/nixos' is dirty
error:
       … while calling anonymous lambda

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/attrsets.nix:1537:24:

         1536|     let f = attrPath:
         1537|       zipAttrsWith (n: values:
             |                        ^
         1538|         let here = attrPath ++ [n]; in

       … while calling anonymous lambda

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/attrsets.nix:1171:18:

         1170|         mapAttrs
         1171|           (name: value:
             |                  ^
         1172|             if isAttrs value && cond value

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/attrsets.nix:1174:18:

         1173|             then recurse (path ++ [ name ]) value
         1174|             else f (path ++ [ name ]) value);
             |                  ^
         1175|     in

       … while calling anonymous lambda

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:242:72:

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

       … while evaluating the option `system.build.toplevel':

       … while calling anonymous lambda

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:824:28:

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

       … while evaluating definitions from `/nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/nixos/modules/system/activation/top-level.nix':

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:825:137:

          824|         defs' = concatMap (m:
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          826|         ) defs;

       … while calling 'dischargeProperties'

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:896:25:

          895|   */
          896|   dischargeProperties = def:
             |                         ^
          897|     if def._type or "" == "merge" then

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/nixos/modules/system/activation/top-level.nix:71:12:

           70|   # Replace runtime dependencies
           71|   system = foldr ({ oldDependency, newDependency }: drv:
             |            ^
           72|       pkgs.replaceDependency { inherit oldDependency newDependency drv; }

       … while calling 'foldr'

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

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

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-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/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/lists.nix:124:15:

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

       … while calling anonymous lambda

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/attrsets.nix:1171:18:

         1170|         mapAttrs
         1171|           (name: value:
             |                  ^
         1172|             if isAttrs value && cond value

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/attrsets.nix:1174:18:

         1173|             then recurse (path ++ [ name ]) value
         1174|             else f (path ++ [ name ]) value);
             |                  ^
         1175|     in

       … while calling anonymous lambda

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:242:72:

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

       … while evaluating the option `assertions':

       … while calling anonymous lambda

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:824:28:

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

       … while evaluating definitions from `/nix/store/y53gk4mmjy439pjasf2pris8nb91ngry-source/nixos/common.nix':

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:825:137:

          824|         defs' = concatMap (m:
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          826|         ) defs;

       … while calling 'dischargeProperties'

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:896:25:

          895|   */
          896|   dischargeProperties = def:
             |                         ^
          897|     if def._type or "" == "merge" then

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:902:11:

          901|         if def.condition then
          902|           dischargeProperties def.content
             |           ^
          903|         else

       … while calling 'dischargeProperties'

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:896:25:

          895|   */
          896|   dischargeProperties = def:
             |                         ^
          897|     if def._type or "" == "merge" then

       … from call site

         at /nix/store/y53gk4mmjy439pjasf2pris8nb91ngry-source/nixos/common.nix:109:20:

          108|
          109|       assertions = flatten (flip mapAttrsToList cfg.users (user: config:
             |                    ^
          110|         flip map config.assertions (assertion: {

       … while calling 'flatten'

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/lists.nix:383:13:

          382|   */
          383|   flatten = x:
             |             ^
          384|     if isList x

       … while calling anonymous lambda

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/lists.nix:385:21:

          384|     if isList x
          385|     then concatMap (y: flatten y) x
             |                     ^
          386|     else [x];

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/lists.nix:385:24:

          384|     if isList x
          385|     then concatMap (y: flatten y) x
             |                        ^
          386|     else [x];

       … while calling 'flatten'

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/lists.nix:383:13:

          382|   */
          383|   flatten = x:
             |             ^
          384|     if isList x

       … while calling anonymous lambda

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/attrsets.nix:1062:10:

         1061|     attrs:
         1062|     map (name: f name attrs.${name}) (attrNames attrs);
             |          ^
         1063|

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/attrsets.nix:1062:16:

         1061|     attrs:
         1062|     map (name: f name attrs.${name}) (attrNames attrs);
             |                ^
         1063|

       … while calling anonymous lambda

         at /nix/store/y53gk4mmjy439pjasf2pris8nb91ngry-source/nixos/common.nix:109:66:

          108|
          109|       assertions = flatten (flip mapAttrsToList cfg.users (user: config:
             |                                                                  ^
          110|         flip map config.assertions (assertion: {

       … from call site

         at /nix/store/y53gk4mmjy439pjasf2pris8nb91ngry-source/nixos/common.nix:110:9:

          109|       assertions = flatten (flip mapAttrsToList cfg.users (user: config:
          110|         flip map config.assertions (assertion: {
             |         ^
          111|           inherit (assertion) assertion;

       … while calling 'flip'

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/trivial.nix:314:16:

          313|   */
          314|   flip = f: a: b: f b a;
             |                ^
          315|

       … while calling anonymous lambda

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/types.nix:584:22:

          583|       merge = loc: defs:
          584|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                      ^
          585|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:846:59:

          845|       if isDefined then
          846|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |                                                           ^
          847|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

       … while calling 'merge'

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/types.nix:888:22:

          887|         check = x: isAttrs x || isFunction x || path.check x;
          888|         merge = loc: defs:
             |                      ^
          889|           (base.extendModules {

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-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/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/attrsets.nix:1167:5:

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

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-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/6bf943g0mlhymyffs9dflzgc78r93s60-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/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:229:25:

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

       … while calling anonymous lambda

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-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/6bf943g0mlhymyffs9dflzgc78r93s60-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/6bf943g0mlhymyffs9dflzgc78r93s60-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/6bf943g0mlhymyffs9dflzgc78r93s60-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/6bf943g0mlhymyffs9dflzgc78r93s60-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/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:365:11:

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

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-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/6bf943g0mlhymyffs9dflzgc78r93s60-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/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:354:14:

          353|           throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
          354|         else unifyModuleSyntax (toString m) (toString m) (applyModuleArgsIfFunction (toString m) (import m) args);
             |              ^
          355|

       … while calling 'unifyModuleSyntax'

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:454:34:

          453|      of ‘options’, ‘config’ and ‘imports’ attributes. */
          454|   unifyModuleSyntax = file: key: m:
             |                                  ^
          455|     let

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:354:59:

          353|           throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
          354|         else unifyModuleSyntax (toString m) (toString m) (applyModuleArgsIfFunction (toString m) (import m) args);
             |                                                           ^
          355|

       … while calling 'applyModuleArgsIfFunction'

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:488:39:

          487|
          488|   applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }:
             |                                       ^
          489|     if isFunction f then applyModuleArgs key f args else f;

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:489:26:

          488|   applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }:
          489|     if isFunction f then applyModuleArgs key f args else f;
             |                          ^
          490|

       … while calling 'applyModuleArgs'

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:491:29:

          490|
          491|   applyModuleArgs = key: f: args@{ config, options, lib, ... }:
             |                             ^
          492|     let

       … from call site

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-source/lib/modules.nix:515:8:

          514|       # works.
          515|     in f (args // extraArgs);
             |        ^
          516|

       … while calling anonymous lambda

         at /nix/store/5rgr39d2s9171l1g7abpwi3njnwk808f-home-manager/fonts/feather-font.nix:1:1:

            1| { stdenv, fetchgit, ... }:
             | ^
            2|

       … while calling anonymous lambda

         at /nix/store/6bf943g0mlhymyffs9dflzgc78r93s60-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 `stdenv' in "/nix/store/5rgr39d2s9171l1g7abpwi3njnwk808f-home-manager/fonts/feather-font.nix":

       error: infinite recursion encountered

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

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

Here’s the home.nix aswell:

{ config, pkgs, inputs, ... }:

let
  home-manager-modules-path = ./../../modules/home-manager;
  hmmp = home-manager-modules-path;
in
{
  imports =
    [
      "${hmmp}/nixvim/nixvim.nix"
      "${hmmp}/git/git.nix"
      "${hmmp}/alacritty/default.nix"
      "${hmmp}/zsh/default.nix"
      "${hmmp}/tmux/default.nix"
      "${hmmp}/hyprland/default.nix"
      "${hmmp}/wofi/default.nix"
      #"${hmmp}/swww/default.nix"
      "${hmmp}/fonts/feather-font.nix"
    ];

  home.username = "luh";
  home.homeDirectory = "/home/luh";

  # link the configuration file in current directory to the specified location in home directory
  # home.file.".config/i3/wallpaper.jpg".source = ./wallpaper.jpg;

  # link all files in `./scripts` to `~/.config/i3/scripts`
  # home.file.".config/i3/scripts" = {
  #   source = ./scripts;
  #   recursive = true;   # link recursively
  #   executable = true;  # make all files executable
  # };

  home.file.".config/eww"  = {
    source = "${hmmp}/eww";
    recursive = true;
    executable = true;
  };

  # encode the file content in nix configuration file directly
  # home.file.".xxx".text = ''
  #     xxx
  # '';

  nixpkgs = {
    config = {
      allowUnfree = true;
      allowUnfreePredicate = (_: true);
    };
  };

  # Packages that should be installed to the user profile.
  home.packages = with pkgs; [
    # here is some command line tools I use frequently
    # feel free to add your own or remove some of them

    pfetch-rs

    # archives
    zip
    xz
    unzip
    p7zip

    # utils
    ripgrep # recursively searches directories for a regex pattern
    #jq # A lightweight and flexible command-line JSON processor
    #yq-go # yaml processor https://github.com/mikefarah/yq
    eza # A modern replacement for ‘ls’
    fzf # A command-line fuzzy finder
    zoxide
    thefuck
    tmux

    # networking tools
    #mtr # A network diagnostic tool
    #iperf3
    #dnsutils  # `dig` + `nslookup`
    #ldns # replacement of `dig`, it provide the command `drill`
    #aria2 # A lightweight multi-protocol & multi-source command-line download utility
    #socat # replacement of openbsd-netcat
    #nmap # A utility for network discovery and security auditing
    ipcalc  # it is a calculator for the IPv4/v6 addresses

    # misc
    cowsay
    file
    which
    tree
    gnused
    gnutar
    gawk
    zstd
    gnupg

    # nix related
    #
    # it provides the command `nom` works just like `nix`
    # with more details log output
    nix-output-monitor

    # productivity
    #hugo # static site generator
    glow # markdown previewer in terminal

    btop  # replacement of htop/nmon
    iotop # io monitoring
    iftop # network monitoring

    # system call monitoring
    strace # system call monitoring
    ltrace # library call monitoring
    lsof # list open files

    # system tools
    sysstat
    lm_sensors # for `sensors` command
    ethtool
    pciutils # lspci
    usbutils # lsusb
    #neovim
    #nixvim
    discord
    steam
    spotify
    ninja
    gcc

    xclip

    dunst
    libnotify

    playerctl
    grimblast

    plymouth

    inputs.swww.packages.${pkgs.system}.swww

    dolphin
    feh
    imlib2Full
    haruna

    bibata-cursors

    eww
    spotifyd
    bash
  ];

  #stylix.package = inputs.stylix.homeMangerModules.stylix;

  #stylix.enable = true;

  #services.hyprpaper.enable = true;

  # This value determines the home Manager release that your
  # configuration is compatible with. This helps avoid breakage
  # when a new home Manager release introduces backwards
  # incompatible changes.
  #
  # You can update home Manager without changing this value. See
  # the home Manager release notes for a list of state version
  # changes in each release.
  home.stateVersion = "23.11";

  # Let home Manager install and manage itself.
  programs.home-manager.enable = true;
}

Post your home.nix, please.

Sure, I edited the post

The gist you linked is not a module, but a package. Including it in the imports list is the problem; you instead should call pkgs.callPackage ./path/to/package.nix { }, and the result will be something you can include somewhere that is expecting a font package (fonts.packages for NixOS, home.packages for Home Manager).

2 Likes

Thanks! You’re a legend!