BUG: Recursion error when consuming `self.outputs.overlays`
Description
Bug reproduction: https://github.com/musjj/recursion-bug/blob/main/modules/defaults.nix Regression report: https://github.com/musjj/recursion-bug/actions/runs/26697561165
This used to work for v0.16.0, but was broken on the v0.17.0 update.
I was unable to reproduce the bug in the test harness, no matter what I tried. So the reproduction above is done using a normal config:
{
self,
den,
lib,
...
}:
let
nixpkgsClass =
ctx:
lib.optionalAttrs
(lib.elem (lib.attrNames ctx) [
[ "home" ]
[ "host" ]
])
(
{ class, aspect-chain }:
den._.forward {
each = [ (ctx.home or ctx.host) ];
fromClass = _: "nixpkgs";
intoClass = { class, ... }: class;
intoPath = _: [ "nixpkgs" ];
fromAspect = _: lib.head aspect-chain;
adaptArgs = lib.id;
}
);
in
{
den.hosts.x86_64-linux.igloo.users.tux.classes = [ "homeManager" ];
den.default = {
includes = [ nixpkgsClass ];
nixpkgs.overlays = builtins.attrValues self.outputs.overlays;
nixos = {
system.stateVersion = "26.05";
boot.loader.grub.device = "nodev";
fileSystems."/" = {
device = "/dev/sda1";
fsType = "ext4";
};
users.users.tux.isNormalUser = true;
};
homeManager.home.stateVersion = "26.05";
};
}
The error only occurs under these two conditions:
self.outputs.overlaysis consumed by thenixpkgsforwarder classhomeManagerclass is set for theigloo.users.tuxentity
Another strange thing is that the error message is slightly different when ran locally and in the CI.
Local error:
error: infinite recursion encountered
at «flakes-internal»/call-flake.nix:72:44:
71|
72| outputs = flake.outputs (inputs // { self = result; });
| ^
73|
error: infinite recursion encountered
at «github:hercules-ci/flake-parts/5792860»/lib.nix:139:21:
138| specialArgs = {
139| inherit self flake-parts-lib moduleLocation;
| ^
140| inputs = args.inputs or /* legacy, warned above */ self.inputs;
They're both recursion errors, but it happens in different places for some reason.
Related: https://github.com/denful/den/issues/575
I'm looking to see if I can fix this more generally, but this issue is avoided if you actually register nixpkgs in den.classes. It's not a forwards issue, it's a resolution issue on self.outputs.
Thank you, the test now passes: https://github.com/musjj/recursion-bug/actions/runs/26722244490/job/78751309372
Should I migrate all den._.forward to the new den.policies? Should the old forwarder be deprecated in favor of policies?
I'm not planning on breaking backwards compatibility any time soon, but as den moves towards a graph based model policies as edges will be more expressive going forward.
Feel free to justify deferring it, there may be some enhanced policy keywords for you in the near future. :)
Yeah, I'm just wondering if policies are somehow more robust because I stumbled upon yet another config-breaking forwarder bug here: https://github.com/denful/den/issues/583
Though at this point, I'm afraid of refactoring my forwarders to policies and stumbling upon even more subtle and hard-to-debug bugs...
@musjj would you like to share your configuration with me and I can verify both 0.16 and 0.17 build equivalent derivations?
Thank you for offering help, I really appreciate it!
My config is really a mess right now and contains way too many PII that I don't currently feel comfortable sharing. But I'll be sure to write more reproducible bug reports if I come across any!
I'll probably use https://github.com/oddlama/nixos-config-tui before fully committing to the new version.
Thank you for offering help, I really appreciate it!
My config is really a mess right now and contains way too many PII that I don't currently feel comfortable sharing. But I'll be sure to write more reproducible bug reports if I come across any!
I'll probably use https://github.com/oddlama/nixos-config-tui before fully committing to the new version.
You can also use our own diagram generator here: https://github.com/denful/den/blob/main/templates/diagram-demo/modules/diagrams.nix