Skip to content

Infinite recursion when using namespace in home configuration #142

@Bear-03

Description

@Bear-03

Hello.

I am trying to build a simple flake with snowfall, but when I try to use a namespaced module in my home configuration, I get the following error:

building the system configuration...
error:
       … while calling the 'head' builtin
         at /nix/store/4r8s42c9mwfvgdlxv0izb1cmlzrsb5nz-source/lib/attrsets.nix:1574:11:
         1573|         || pred here (elemAt values 1) (head values) then
         1574|           head values
             |           ^
         1575|         else

       … while evaluating the attribute 'value'
         at /nix/store/4r8s42c9mwfvgdlxv0izb1cmlzrsb5nz-source/lib/modules.nix:816:9:
          815|     in warnDeprecation opt //
          816|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          817|         inherit (res.defsFinal') highestPrio;

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

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

       … while evaluating the option `assertions':

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

       … while evaluating the module argument `namespace' in "/nix/store/9bwi858z3pzcgf9g40bwqvr52lz2zycd-s6wc8mk3jb8ja70aawm5s0ndmda1cyvh-source/homes/x86_64-linux/bear@nixos-laptop/default.nix":

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

       error: infinite recursion encountered
       at /nix/store/4r8s42c9mwfvgdlxv0izb1cmlzrsb5nz-source/lib/modules.nix:515:28:
          514|         addErrorContext (context name)
          515|           (args.${name} or config._module.args.${name})
             |                            ^
          516|       ) (functionArgs f);

I am fairly surprised this is happening since the flake is as small as it can get. Just a module, a home configuration file and a system configuration file; here's their contents:

# modules/home/foo/default.nix
{ namespace, lib, ... }:
with lib;
{
    options."${namespace}".foo = {
        enable = mkEnableOption "Foo";
    };
}
# homes/x86_64-linux/bear@nixos-laptop
{ pkgs, lib, namespace, ... }:
{
    "${namespace}".foo.enable = true;
    home.stateVersion = "24.05";
}
# systems/x86_64-linux/nixos-laptop
{ config, namespace, lib, pkgs, ... }:
{
    imports = [./hardware.nix];

    users.users."bear" = {
        isNormalUser = true;
    };

    system.stateVersion = "24.05";
}
# flake.nix
{
    description = "DataMarket's NixOS flake";

    inputs = {
        # Nix Packages
        nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

        # Snowfall
        snowfall-lib = {
            url = "github:snowfallorg/lib";
            inputs.nixpkgs.follows = "nixpkgs";
        };

        # Home Manager
        home-manager = {
            url = "github:nix-community/home-manager/release-24.05";
            inputs.nixpkgs.follows = "nixpkgs";
        };
    };

    outputs = inputs: inputs.snowfall-lib.mkFlake {
        inherit inputs;
        src = ./.;

        channels-config = {
            allowUnfree = true;
        };
    };
};

If i change "${namespace}" to a hardcoded internal in the line the module is enabled, it works.

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions