Nixos rebuild switch building openjdk for no reason and failing because of cyclic dependency

So Im new to nix os and I installed it like two weeks ago and in that time I have configured a bunch of stuff in my /etc/nixos/configuration.nix. Now Ive decided to enable flakes and install homemanager.
So I enabled flakes by adding nix.settings.experimental-features = [ "nix-command" "flakes" ]; to my configuration and made a flake.nix file where my /etc/nixos/configuration.nix is referenced as a module.

Then I ran sudo nixos-rebuild switch --flake /etc/nixos#nixos which started building openjdk and after a while gave me this error:
error: cycle detected in build of '/nix/store/pih5qinxqs3wbs2x8wjrnr39h8hp8yg2-openjdk-8u442-b06.drv' in the references of output 'jre' from output 'out'.

I did have openjdk in my environment.systemPackages at that time but didnt necessarily need it so I removed it for now in hope to maybe find a solution some other time, but after doing that, it just still gave me the error. Ive also tried removing nix.settings.experimental-features = [ "nix-command" "flakes" ];again and rebuilding nix with just sudo nixos-rebuild switch but no change.

Ok thats good to know, but I dont even have OpenJDK 8 in my configuration. How do I know which package needs it so I can remove that for now instead. Or should I just switch to nixpkgs stable?

Update: I am now using nixpkgs 25.05 and its working

You may depend indirectly, as a few packages still depend on openjdk8.

Current nixos-unstable should have this fixed already:
https://nixpk.gs/pr-tracker.html?pr=425561