All flakes I have tried to put into my /etc/nixos directory (this is including the default flake generated by sudo nix flake init) cause nixos-rebuild switch or nixos-rebuild switch --flake /etc/nixos (it does not matter which one I use) to return this error:
error: flake 'path:/etc/nixos' does not provide attribute 'packages.x86_64-linux.nixosConfigurations."nixos".config.system.build.nixos-rebuild', 'legacyPackages.x86_64-linux.nixosConfigurations."nixos".config.system.build.nixos-rebuild' or 'nixosConfigurations."nixos".config.system.build.nixos-rebuild'
I am saying “all” flakes because the default flake causes the same issue as any others I tried. I am saying they cause this issue because when I delete the flake, nixos-rebuild switch works just fine. My issue began with others I was using trying to follow this tutorial, but then I tested with the default one and discovered it must be a deeper problem. I have no idea how to navigate this, or what kind of information I should include. The same error seems to have appeared for other people, but it always seemed to be a problem with code that my unedited flake.nix did not even have. I am at a loss. Is this the result of a classic stupid mistake? Is there information I can give that might help suss out the problem? Please let me know.