den icon indicating copy to clipboard operation
den copied to clipboard

Chained custom forward classes hit "already declared" on the inner hop (#603 regression)

Open sini opened this issue 4 months ago • 1 comments

Found while fixing #642 (PR #643). Same error shape, different producer pair; not fixed by that PR.

Symptom

Two custom forward classes chained — inner → mid, then mid → homeManager:

error: The option `home-manager.users.tux.den.fwd."inner/mid/programs/bash"'
       is already declared in `…/flake.nix'.

The collision is on the inner hop's declaration, not the one PR #643 suppresses.

Repro

test-chained-forward-with-host-aspects = denTest (
  { den, lib, tuxHm, ... }:
  let
    innerClass =
      { class, aspect-chain }:
      den._.forward {
        each = lib.singleton class;
        fromClass = _: "inner";
        intoClass = _: "mid";
        intoPath = _: [ "programs" "bash" ];
        fromAspect = _: lib.last aspect-chain;
        guard = _: true;
      };
    midClass =
      { class, aspect-chain }:
      den._.forward {
        each = lib.singleton class;
        fromClass = _: "mid";
        intoClass = _: "homeManager";
        intoPath = _: [ ];
        fromAspect = _: lib.last aspect-chain;
      };
  in
  {
    den.default.includes = [ den._.host-aspects innerClass midClass ];

    den.aspects.chained.inner.enable = true;

    den.hosts.x86_64-linux.igloo.users.tux = { };
    den.aspects.tux.includes = [ den.aspects.chained ];

    expr = tuxHm.programs.bash.enable or "<stranded>";
    expected = true;
  }
);

Attribution

  • Passes at 88161dab (parent of 41aa2558), fails at 41aa2558 and at HEAD ⇒ a #603 regression.
  • Fails identically with and without PR #643 applied, so that suppression neither causes nor cures it.
  • Content is not stranded: an earlier variant of this repro pointing at a non-existent target option failed with The option home-manager.users.tux.programs.chained does not exist, showing the chained content does arrive. The defect is purely the duplicated declaration.

PR #643 leaves the parent pipeline's copy as the single owner for routes whose declaration lands in the spawn's extracted class. For an intermediate custom class the declaration lands in another bucket first and reaches the target through the second hop, so a second producer survives.

sini avatar Jul 31 '26 17:07 sini

Fixed in #643 (14d07a1f) — declaration-bearing routes now give the parent precedence on both sides of the spawn merge, matched by route identity rather than target class so the indirect hop is caught. Regression suite issue-645-chained-forward-classes.

sini avatar Jul 31 '26 17:07 sini