Skip to content

nixos/version: Warn about using the default of system.stateVersion#124261

Merged
dasJ merged 3 commits intoNixOS:masterfrom
helsinki-systems:feat/state-version-default-warn
May 6, 2022
Merged

nixos/version: Warn about using the default of system.stateVersion#124261
dasJ merged 3 commits intoNixOS:masterfrom
helsinki-systems:feat/state-version-default-warn

Conversation

@dasJ
Copy link
Member

@dasJ dasJ commented May 24, 2021

Motivation for this change

Using the default which switches every release is dangerous and potentially breaking when upgrading to a new release.
This should be required in the future but it will only be a warning for now.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • 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 nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Added a release notes entry if the change is major or breaking
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels May 24, 2021
@mweinelt mweinelt requested a review from jonringer May 24, 2021 14:17
@mweinelt
Copy link
Member

mweinelt commented May 24, 2021

I think this is worth backporting, since it prevents unexpected issues and otherwise does not have a negative impact.

@mweinelt mweinelt added the 9.needs: port to stable A PR needs a backport to the stable release. label May 24, 2021
Copy link
Member

@Synthetica9 Synthetica9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also throws a warning for all(?) NixOS tests.

I see a two of solutions:

  • Explicitly set stateVersion to the old default in the test builder
  • Add an option to specify that the system is only short-lived and should therefore not get this warning.

(+1 for the idea tho 👍🏻)

@dasJ dasJ force-pushed the feat/state-version-default-warn branch from b1fc031 to afb3ce9 Compare May 24, 2021 14:46
@dasJ
Copy link
Member Author

dasJ commented May 24, 2021

@mweinelt Thanks, force pushed

@Synthetica9 Can you point me in the right direction on where to set this in the test runner? I really have no idea where to look. Edit: Do I just add it to build-vms.nix into buildVm?

@NixOS/nixos-release-managers Do you think this should be backported to 21.05? (assuming I can get rid of the warnings in the tests)

@Synthetica9
Copy link
Member

@Synthetica9 Can you point me in the right direction on where to set this in the test runner? I really have no idea where to look. Edit: Do I just add it to build-vms.nix into buildVm?

I think adding a new module to baseModules where you override the default should work, but I haven't tested that.

@Synthetica9
Copy link
Member

Synthetica9 commented May 24, 2021

Actually, you should probably add it to https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/testing/test-instrumentation.nix:

diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix
index be5fa88b8ad..774738d0be1 100644
--- a/nixos/modules/testing/test-instrumentation.nix
+++ b/nixos/modules/testing/test-instrumentation.nix
@@ -129,6 +129,9 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; };
     # Make sure we use the Guest Agent from the QEMU package for testing
     # to reduce the closure size required for the tests.
     services.qemuGuest.package = pkgs.qemu_test.ga;
+
+    # Squelch warning about unset system.stateVersion
+    system.stateVersion = lib.trivial.release;
   };
 
 }

@dasJ
Copy link
Member Author

dasJ commented May 24, 2021

Fixed and rebased

@dasJ dasJ force-pushed the feat/state-version-default-warn branch from afb3ce9 to fe44f8c Compare May 24, 2021 21:03
@dasJ dasJ force-pushed the feat/state-version-default-warn branch from fe44f8c to 4fd787a Compare May 24, 2021 21:24
Copy link
Member

@Synthetica9 Synthetica9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good change, reducing the amount of footguns in NixOS

@dasJ dasJ force-pushed the feat/state-version-default-warn branch from 4fd787a to 9a4a241 Compare May 25, 2021 14:56
@dotlambda
Copy link
Member

@NixOS/nixos-release-managers Do you think this should be backported to 21.05? (assuming I can get rid of the warnings in the tests)

I would say yes. This has only positive affects as long as ofborg is happy.

@dasJ
Copy link
Member Author

dasJ commented May 25, 2021

@grahamc Any idea about the eval error? That would probably affect other PRs as well once this is merged

@dotlambda
Copy link
Member

@dasJ If you temporarily replace warnings with assertions ofborg should print the trace.

@ofborg ofborg bot added 8.has: clean-up This PR removes packages or removes other cruft 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels May 25, 2021
@dasJ dasJ force-pushed the feat/state-version-default-warn branch from 0ebbdd0 to 9a4a241 Compare May 25, 2021 20:54
@dasJ
Copy link
Member Author

dasJ commented May 25, 2021

Nope, adding an assertion fixes the eval

@dasJ
Copy link
Member Author

dasJ commented May 26, 2021

Weird, running PAGER=true NIX_PATH= nix-env -qaP --no-name --out-path -f $PWD --arg checkMeta true locally (which is the closest I can get to ofborg I guess), the warning does not get logged.

@dotlambda
Copy link
Member

Another idea: How about we temporarily drop the default and see if ofborg shows us a trace?

@dasJ dasJ force-pushed the feat/state-version-default-warn branch from 48a93ad to 5f7a128 Compare May 26, 2021 10:23
@dasJ
Copy link
Member Author

dasJ commented May 26, 2021

I'm out of ideas now

@mohe2015
Copy link
Contributor

mohe2015 commented Aug 25, 2021

@dasJ for https://github.com/NixOS/ofborg#running-meta-checks-locally I get the warning logged but no non-zero exit code (which may mean nothing as ofborg maybe parses that output somehow). I have no idea what that command does though so maybe that doesn't matter.

It eats all your RAM btw (~32 GB or so).

Edit: I'm pretty sure that's the offending command.

@dasJ dasJ force-pushed the feat/state-version-default-warn branch from 5f7a128 to 53e0cd5 Compare May 4, 2022 22:57
@mweinelt mweinelt added the 12.approvals: 3+ This PR was reviewed and approved by three or more persons. label May 4, 2022
@dasJ dasJ force-pushed the feat/state-version-default-warn branch from 53e0cd5 to 0329256 Compare May 5, 2022 10:52
@ofborg ofborg bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels May 5, 2022
@dasJ
Copy link
Member Author

dasJ commented May 5, 2022

Finally, ofborg succeeded 🎉

@dasJ dasJ merged commit 764d77f into NixOS:master May 6, 2022
@dasJ dasJ deleted the feat/state-version-default-warn branch May 6, 2022 11:20
system.nixos = dummyVersioning;
boot.loader.grub.enable = false;
fileSystems."/".device = "/dev/null";
system.stateVersion = lib.trivial.release;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one was redundant because of the default in test-instrumentation.nix. Removing in #171647.

augu5te pushed a commit to oar-team/nixos-compose that referenced this pull request Oct 17, 2022
see NixOS/nixpkgs#124261
for docker I had the choice between the image or the config,
perhaps it makes more sens in the image ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: clean-up This PR removes packages or removes other cruft 8.has: module (update) This PR changes an existing module in `nixos/` 9.needs: port to stable A PR needs a backport to the stable release. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 3+ This PR was reviewed and approved by three or more persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants