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

Renames stateVersion to stateEpoch #50112

Closed
wants to merge 2 commits into from

Conversation

samueldr
Copy link
Member

@samueldr samueldr commented Nov 10, 2018

Motivation for this change

Initially thrown on the wall 2018-10-07.

This change is to reduce the support questions like this:

I changed stateVersion in my configuration.nix and NixOS hasn't been upgraded to the next release. What gives?

Using the release version as a marker to decide between stateful schemas is in itself a good idea, but might not be the best interface to present to the end-users.

Having a monotonically incrementing opaque number will reduce confusion.

The number 100 has been chosen as:

  • It is bigger than 18.09 when compared as a version
  • Allows us to start "at zero" in a new range.

The number would have been 1 if possible, but existing stateVersion = xx.yy; makes it harder to implemented in such a way.

Additionally, decoupling the release version makes it so it is possible to have concurrent incompatible changes in unstable, while staying compatible, making for a better rolling-release approximation.

Things done
  • ✔️ Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • ✔️ NixOS
  • ⬜ Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • ⬜ Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • ⬜ Tested execution of all binary files (usually in ./result/bin/)
  • ⬜ Determined the impact on package closure size (by running nix path-info -S before and after)
  • ✔️ Fits CONTRIBUTING.md.
Expectations

A bit of bikeshedding. A bit of criticism about the implementation.

Please consider the idea and propose better implementations, but don't hang yourself up on details of the implementation. I'm more interested in the big picture than corner case things. Once the big picture is better unveiled, and everything falls in place, the details can be worked out. Thanks.

This is the first part, the noisiest part.
The idea is to decouple that option from the version of NixOS.

Why?

There may be verions where `stateVersion` does not incurr incompatible
changes! There could be development (unstable) versions with multiple
conflicting changes! Decoupling that flag from the operating system
version should, in theory, better represent the intent at all time.
... rather than using the NixOS version.

This change is to reduce the support questions like this:

> I changed `stateVersion` in my `configuration.nix` and NixOS hasn't
> been upgraded to the next release. What gives?

Using the release version as a marker to decide between stateful schemas
is in itself a good idea, but might not be the best interface to present
to the end-users.

Having a monotonically incrementing opaque number will reduce confusion.

The number `100` has been chosen as:

 * It is bigger than 18.09 when compared as a version
 * Allows us to start "at zero" in a new range.

The number would have been `1` if possible, but existing `stateVersion =
xx.yy;` makes it harder to implemented in such a way.
@samueldr
Copy link
Member Author

samueldr commented Nov 10, 2018

From IRC:

[22:25:28] <ekleog> potential issue: release notes were done for releases, now the “manual steps for upgrading” needs to be done in a stateEpoch log which needs to be somewhere
[22:25:42] <samueldr> ekleog: right!
[22:26:01] <samueldr> but thos possibly can be coupled with the release notes
[22:27:13] <samueldr> describing that for 101, foo's stateful directory will move from /dev/null to /dev/urandom, and for 102 bar's configuration file needs to be written in COBOL

So yeah, good point there, this makes it a tad harder to describe the changes in the release notes. Though, while the number itself is uncoupled from the releases, the notes about incompatible changes could realistically still be described in the release notes.

Though, since not all changes requiring an increase in stateEpoch requires to increment it, it's entirely possible that during a single release only one epoch is going to be used. Even possible through two releases, while the following could have three, or more!

@srhb
Copy link
Contributor

srhb commented Nov 11, 2018

While this may cause people to not suddenly bump the variable on their own despite the warnings, I think it's going to increase the support burden, not the other way around, since it still has the same meaning but now has an extra layer of indirection in order to actually understand what's going on. In general, I doubt making the meaning of a certain value more opaque is an improvement.

I think it would be preferable to improve the documentation in both the generated warning and in the actual docs -- a link with some long-form prose in the "don't do this"-comment would be especially good.

@Ekleog
Copy link
Member

Ekleog commented Nov 14, 2018

I personally approve stateEpoch, would it only be for nixos-unstable users to be able to use it without necessarily being forced to opt-in future changes.

I also don't really see what extra layer of indirection there is: it's just comparing a version vs. comparing a digit, it just decouples orthogonal concerns (releases vs. backwards-compat-breakage).

Finally, I think stateEpoch shouldn't have a default value, and should eval-fail if not present: a friend already deleted stateVersion not knowing what it was doing, and the next postgresql update… well, you get the idea.

@infinisil
Copy link
Member

What we'd really need is a state version for everything that needs state separately. So nginx has its state version, postgresql, etc. These are 0 by default and increase on every state incompatible update. Advantages:

  • Allows users to only update/migrate a single part
  • We could implement automatic migrations for some parts and only provide manual ones for others

In addition, these state versions could be stored alongside the data itself, in /var/lib/nixos/stateversion preferably. To be able to access these values in the configuration, we should modify nixos-rebuild to read the target hosts stateversion file and pass it to the configuration at the start. This has the advantage that nobody needs to track this version in their configuration, which I always thought was a bit annoying and unnecessary.

So if we're gonna change how this state version thing works, why not go all out and implement it properly.

@Ekleog
Copy link
Member

Ekleog commented Nov 15, 2018 via email

@infinisil
Copy link
Member

That would make building the configuration impure

Ah right, good point.

Now what we'd need is a separate command nixos-generate-state-versions which fetches the target hosts /var/lib/nixos/stateversion and puts it into an /etc/nixos/state-versions.nix file. But hold on, we pretty much have something like this already, nixos-generate-config for hardware-configuration.nix!

So how about extending nixos-generate-config to output a state version configuration as well. Maybe even integrate it into nixos-rebuild somehow.

@oxij
Copy link
Member

oxij commented Nov 17, 2018 via email

@Ekleog
Copy link
Member

Ekleog commented Mar 18, 2019

@samueldr I think this should be turned into an RFC, and it would basically never merge otherwise, isn't it?

@stale
Copy link

stale bot commented Jun 2, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 2, 2020
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 3, 2020
@stale
Copy link

stale bot commented Apr 7, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 7, 2021
@lucasew
Copy link
Contributor

lucasew commented Aug 24, 2022

Closing as it is abandoned.

@lucasew lucasew closed this Aug 24, 2022
@samueldr samueldr deleted the feature/stateEpoch branch November 26, 2023 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: nixos 8.has: module (update)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants