evaluation warning: system.stateVersion is not set, defaulting to 24.11.
@boxofrox is right, the warnings do not make sense when i read this discussion.
It’s something you shouldn’t need to touch, then it should not give a warning when omitting the value, because then i rather want NixOS to deal with this state version stuff.
But NixOS doesn’t deal with it. It needs to know what version the stateful files on your system is so it can make the right build-time decisions. It doesn’t have a way to know the answer of that unless you specifically tell it.
Then the version should be defined somewhere on the stateful files itself, how can you call the files stateful when it relies on user input via stateVersion, the system doesn’t know which version was used to produce the state? That’s stateless.
That’s the point, right? One of the tenets of nix is that you should be able to put your config in a repo and build the system’s toplevel derivation on any other machine. For that code to account for system state’s expected format / contents, it has to be recorded in the code. That’s exactly what stateVersion is.
No, the files do not rely on stateVersion. The file were produced by whatever apps you ran. stateVersion’s job is to tell the system what versions of the corresponding tooling can work with that state without either breaking the state completely or failing to operate.
There are better ways of doing this, this is just the current way that is used in NixOS.