Nix: Silent schema upgrades are a tad unfriendly

Created on 27 Feb 2017  路  10Comments  路  Source: NixOS/nix

I was testing something (my changes to Nix for #1245) so I cloned master on a remote box I was working on, ran make install, and then ran inst/bin/nix-somehing. I worked on Nix for a while and then switched back to the host, and then all of a sudden all of my Nix commands failed immediately saying error: current Nix store schema is version 10, but I only support 7.

I don't particularly want to upgrade everything in this system to nixUnstable (and even if I did, it'd be kinda painful given that nothing works now). My current plan is to tinker with --dump-db (from nixUnstable) and --load-db (on an older one) and cross my fingers.

I think it'd be nice for some sort of configuration option saying "don't quietly upgrade my store", perhaps on by default. Then a simple nix-upgrade-store command would apply the logic when I ask for it, and all other commands would tell me that they need me to upgrade and that since it's a PITA to reverse, they won't do it for me.

Most helpful comment

This surprise shouldn't be that bad in future, thanks to https://github.com/NixOS/nix/commit/8ca944e009ce395c5040887527dfbcd06faeec39 in current stable Nix.

All 10 comments

For anyone in my situation, this worked:

  1. /path/to/nix/unstable/bin/nix-store --dump-db > /tmp/db.dump
  2. mv /nix/var/nix/db /nix/var/nix/db.toonew
  3. mkdir /nix/var/nix/db
  4. nix-store --init (this is the old nix-store)
  5. nix-store --load-db < /tmp/db.dump
  6. Breathe a sigh of relief that your system isn't hosed

This would make an excellent addition to the wiki/cookbook I think.

This surprise shouldn't be that bad in future, thanks to https://github.com/NixOS/nix/commit/8ca944e009ce395c5040887527dfbcd06faeec39 in current stable Nix.

@vcunat aha, that would've been good to know 馃槃 but in general, I think silently making hard-to-reverse changes is an awkward policy, and we might not always go to the effort to remain forward-compatible. I'd prefer future schema updates to work in the way I'm saying, even though it might be a slightly less smooth user experience.

Added to http://nix-cookbook.readthedocs.io/en/latest/faq.html#how-do-i-fix-error-current-nix-store-schema-is-version-10-but-i-only-support-7

This is particularly unfriendly, I found, when it comes to the automatic nixFallback behavior in nixos-rebuild. In order to use the latest features, nixos-rebuild will automatically fall back to nixUnstable if anything goes wrong during nix-instantiate (even things unrelated to evaluation failures), and in doing so (up until 1.11.7) upgraded the database schema.

Yes, nixFallback is no longer needed now that we have nixos/modules/installer/tools/nix-fallback-paths.nix (which use a stable version). I've removed it.

Awesome, thanks 馃槃

(still going to leave this open since I think that silent breaking upgrades are awkward)

What does the "I" refer to? I'm attempting to use Nixops, but I'm not sure if this refers to my nix store on my machine, or the nix store I'm deploying / targeting to.

Was this page helpful?
0 / 5 - 0 ratings