Skip to content

Eval fails with duplicate nix module option when evaluating with lazy-trees #301

@mrene

Description

@mrene

Describe the bug

I'm exploring using clan.lol for my homelab. While testing I managed to get into a state where determinate-nix would give me an evaluation error due to a duplicate module option definition. The reported filenames didn't exist so I reran it without lazy-trees and the evaluation succeeded.

Steps To Reproduce

I pushed this config to a branch, you can reproduce it with:

$ nix eval --accept-flake-config github:mrene/dotfiles?ref=lazy-tree-eval-bug#nixosConfigurations.beast.config.system.build.toplevel
error:
       … while calling the 'seq' builtin
         at «github:NixOS/nixpkgs/c6f52eb»/lib/modules.nix:361:18:
          360|         options = checked options;
          361|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          362|         _module = checked (config._module);

       … while evaluating a branch condition
         at «github:NixOS/nixpkgs/c6f52eb»/lib/modules.nix:297:9:
          296|       checkUnmatched =
          297|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [ ] then
             |         ^
          298|           let

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

       error: The option `sops.gnupg.home' in `/nix/store/546g40c7c4l44rsy0i6wrvipjwybpyis-source/modules/sops' is already declared in `/nix/store/f09v90dfhv2z2cral2vb0i6zv3nrr30y-source/modules/sops'.

$ ls /nix/store/546g40c7c4l44rsy0i6wrvipjwybpyis-source/modules/sops /nix/store/f09v90dfhv2z2cral2vb0i6zv3nrr30y-source/modules/sops
ls: cannot access '/nix/store/546g40c7c4l44rsy0i6wrvipjwybpyis-source/modules/sops': No such file or directory
ls: cannot access '/nix/store/f09v90dfhv2z2cral2vb0i6zv3nrr30y-source/modules/sops': No such file or directory

Disabling lazy-trees:

❯ nix eval --option lazy-trees false --accept-flake-config github:mrene/dotfiles?ref=lazy-tree-eval-bug#nixosConfigurations.beast.config.system.build.toplevel
error: evaluation of cached failed attribute 'nixosConfigurations.beast.config' unexpectedly succeeded

Disabling both lazy-trees and eval-cache:

❯ nix eval --option eval-cache false --option lazy-trees false --accept-flake-config github:mrene/dotfiles?ref=lazy-tree-eval-bug#nixosConfigurations.beast.config.system.build.toplevel
evaluation warning: 'system' has been renamed to/replaced by 'stdenv.hostPlatform.system'
warning: Using 'builtins.toFile' to create a file named 'options.json' that references the store path '/nix/store/h804a5w2y4cqmzkrcgp37m8804ialqi4-source' without a proper context. The resulting file will not have a correct store reference, so this is unreliable and may stop working in the future.
«derivation /nix/store/9apr571q2f4h7l10ywm8j2wdwq21ipp0-nixos-system-beast-25.11.20251215.c6f52eb.drv»

With nix 2.29.1 (through the nixos/nix docker image)

$ nix eval --accept-flake-config --extra-experimental-features "nix-command flakes" github:mrene/dotfiles?ref=lazy-tree-eval-bug#nixosConfigurations.beast.config.system.build.toplevel
«derivation /nix/store/9apr571q2f4h7l10ywm8j2wdwq21ipp0-nixos-system-beast-25.11.20251215.c6f52eb.drv»

Expected behavior

Evaluation succeeds, or a clear error message lets me know which module is imported twice.

Metadata

Determinate Nixd daemon version: 3.15.0
Determinate Nixd client version: 3.15.0

You are running the latest version of Determinate Nix.

The following features are enabled:

  • lazy-trees

Visit https://dtr.mn/features for more information.

nix (Determinate Nix 3.15.0) 2.33.0

Additional context

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions