Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NixOS upgrades may break due to lack of stateVersion #33

Open
roberth opened this issue Jul 18, 2020 · 5 comments
Open

NixOS upgrades may break due to lack of stateVersion #33

roberth opened this issue Jul 18, 2020 · 5 comments

Comments

@roberth
Copy link
Contributor

roberth commented Jul 18, 2020

Describe the bug

Installations of NixOS should set the stateVersion option, such that NixOS can take legacy filesystem state locations and such into account.

To Reproduce

(hypothetical but bound to happen)

  1. Deploy NixOS, say 19.09. This creates a system state compatible with 19.09.
  2. Deploy NixOS, say 20.03. This now expects a system state that is like a fresh 20.03 install. It does not apply its compatibility measures, because it doesn't know that the system is still in a 19.09-like state.
  3. A database is down because the files are in the 19.09 location rather than the fresh 20.03 location and another service is misconfigured because the default values for its options have changed

Expected behavior
terraform-nixos saves the stateVersion on first deployment and sets it until the machine is destroyed.

Environment

  • OS name + version: n/a
  • Version of the code: master as of reporting

Additional context

From the docs

Every once in a while, a new NixOS release may change configuration defaults in a way incompatible with stateful data. For instance, if the default version of PostgreSQL changes, the new version will probably be unable to read your existing databases. To prevent such breakage, you should set the value of this option to the NixOS release with which you want to be compatible. The effect is that NixOS will use defaults corresponding to the specified release (such as using an older version of PostgreSQL). It‘s perfectly fine and recommended to leave this value at the release version of the first install of this system. Changing this option will not upgrade your system. In fact it is meant to stay constant exactly when you upgrade your system. You should only bump this option, if you are sure that you can or have migrated all state on your system which is affected by this option.

@exarkun
Copy link
Contributor

exarkun commented Dec 9, 2021

Why isn't it the configuration.nix author's job to set stateVersion in their configuration to prevent this?

@zimbatm
Copy link
Member

zimbatm commented Dec 9, 2021

Agreed. The terraform-nixos project should probably mention that responsibility though.

@zimbatm
Copy link
Member

zimbatm commented Dec 9, 2021

Actually, NixOS should probably also fail to evaluate without the stateVersion.

@exarkun
Copy link
Contributor

exarkun commented Dec 9, 2021

Actually, NixOS should probably also fail to evaluate without the stateVersion.

Sounds good to me (maybe only if it tries to use it). Certainly also not terraform-nixos's responsibility.

@zimbatm
Copy link
Member

zimbatm commented Dec 11, 2021

I started here: NixOS/nixpkgs#149877

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants