Skip to content

Fail to install due to "infinite recursion encountered" #77

@Wishmater

Description

@Wishmater

What Happened?

Hi, I'm relatively new to NixOS, so please bear with me if I'm missing something stupid and thanks for any help.

I'm trying to install nixos-cli without flakes like described here. I added this module file, which is added to imports list in configuration.nix:

{ config, system, pkgs, ... }:

let
  # In pure evaluation mode, always use a full Git commit hash instead of a branch name.
  nixos-cli-url =
    "https://github.com/nix-community/nixos-cli/archive/refs/tags/0.12.2.tar.gz";
  nixos-cli = import "${builtins.fetchTarball nixos-cli-url}" { inherit pkgs; };
in {
  imports = [ nixos-cli.module ];

  services.nixos-cli = {
    enable = true;
    package = nixos-cli.nixosLegacy;
    config = {
      # Other configuration for nixos-cli
    };
  };

  nix.settings = {
    substituters = [ "https://watersucks.cachix.org" ];
    trusted-public-keys = [
      "watersucks.cachix.org-1:6gadPC5R8iLWQ3EUtfu3GFrVY7X6I4Fwz/ihW25Jbv8="
    ];
  };
}

Now, when running nixos-rebuild switch, I get the following error:

sudo nixos-rebuild test
error:
       … while evaluating the attribute 'config'
         at /nix/store/5xmkn8kbn69nrxsk9qk85kp00mhkjx8k-nixos-25.05.802746.7282cb574e06/nixos/lib/modules.nix:359:9:
          358|         options = checked options;
          359|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          360|         _module = checked (config._module);

       … while calling the 'seq' builtin
         at /nix/store/5xmkn8kbn69nrxsk9qk85kp00mhkjx8k-nixos-25.05.802746.7282cb574e06/nixos/lib/modules.nix:359:18:
          358|         options = checked options;
          359|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          360|         _module = checked (config._module);

       … while evaluating the module argument `pkgs' in "/home/wish/nixos_config/config/nixos-cli.nix":

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: infinite recursion encountered
       at /nix/store/5xmkn8kbn69nrxsk9qk85kp00mhkjx8k-nixos-25.05.802746.7282cb574e06/nixos/lib/modules.nix:652:66:
          651|       extraArgs = mapAttrs (
          652|         name: _: addErrorContext (context name) (args.${name} or config._module.args.${name})
             |                                                                  ^
          653|       ) (functionArgs f);

I tried commenting out the whole services.nixos.cli block and the nix.settings block for the cache, and I still get the same error. Just adding imports = [ nixos-cli.module ] causes it.

I understand this might be due to something specific in my config, but I find it impossible to debug without any information on exactly what cause the conflict... any help would be appreciated. Also, my config has nothing 'weird' that might cause this, only nixos options and adding pkgs to systemPkgs, I'm not even using flakes. Using NixOS 25.05, btw.

How To Reproduce

Install with nixosLegacy like described in documentation.

Expected Behavior

nixos-rebuild is successful.

Features

Can't run because install doesn't work.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinglegacyThis is related to the legacy executable

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions