List and update stateVersion and installed packages?

Hello, I am using flakes and the new cli. I recently added programs.firefox.enable = true to my home-manager configuration. According to the code in nixpkgs, this option evaluates the normal firefox package if the stateVersion is higher than 19, otherwise the firefox-unwrapped one.

Are there some easy, modern CLI commands to check what state version I am currently on and if firefox or firefox-unwrapped was installed?

Also, can I somehow update the stateVersion? I know this is not recommended, but I am currently on nixos-unstable (23.11), and my stateVersion is still only on 22.11.

Thank you very much :slight_smile:

stateVersion should be set in your config.

Unless you know what you are doing, you are not supposed to change that.

The stateVersion is specified at the bottom of the generated configuration.nix, along with some pointers to docs about it. (You might see it with tail /etc/nixos/configuration.nix.)

I think of stateVersion as the nixos config API version identifier. Occasionally some module syntax changes in breaking way. When this happens, the nixos-rebuild output will display warnings about what changed and how to fix it.

When I get those warnings, I review the nixOS Release Notes to better understand the change and how it affects my systems. I update my config with the change and update stateVersion to the matching nixOS version, and then re-run nixos-rebuild.

stateVersion is mostly only used if an automatic migration is not possible eg with postgres or when older versions of a package are removed eg nextcloud.

1 Like