I’ve been changing my NixOS config to parameterize my config modules using options declarations. This has been working fine, except for my XServer config. The below is a minimal version of the offending module:
When I include that module from my NixOS config, and set os.xorg.enable = true; from another module, I get the following error when I sudo nixos-rebuild test --flake '.':
error: infinite recursion encountered
at /nix/store/kmy3yfc596gvfm5lkxzbq37kxizdj78r-source/lib/types.nix:461:58:
460| # Push down position info.
461| (map (def: mapAttrs (n: v: { inherit (def) file; value = v; }) def.value) defs);
| ^
462| emptyValue = { value = {}; };
--show-trace does not seem to produce any useful results; I can attach those if wanted.
If I comment out enable = true and the LightDM config block, it seems to move forwards. Similarly, if I comment out the options block, the config = mkIf ... line, and the corresponding ending curly brace, it works fine.
Expected outcome
I’d expect to be able to parameterize this module, like I’ve done with others.
The machine in question is an AMD A10-7850K; it seems to be using the radeon driver for graphics. I haven’t tried it on other machines yet; that’s next I suppose.
Playing around a bit more, I find if I comment out the two lines pointed out below, the module gets past the error message. I’ve always killed the process at that point – not interested in leaving my system without X or a graphical login screen…
config.services.xserver = mkIf config.os.xorg.enable {
#enable = true; # <-- commented this line
displayManager.lightdm = {
#enable = true; # <-- and this line
greeters.enso = {
enable = true;
blur = true;
};
};
};
I made a minimal replication of the issue, which I’ve uploaded here:
All I need to replicate the problem is to check this out somewhere and run
nixos-rebuild build --flake '.#infrectest'
to see the problem.
Any thoughts are welcome – I’m still not counting out that I’ve missed something/done something wrong/have a bad mental model!
(Edit: Changed command to do nixos-rebuild build instead of nixos-rebuild switch, which is correctly pointed out as dangerous on an arbitrary machine – thanks NobbZ)