From 5b5e4d4e687ad87d460317b1dfbdb51eb6a5f26a Mon Sep 17 00:00:00 2001 From: Aristid Breitkreuz Date: Tue, 23 Jul 2019 22:07:44 +0200 Subject: [PATCH 1/3] make nixos.stateVersion mandatory --- nixos/modules/misc/version.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index 3ae60cb791601..2e4a176f037a6 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -49,7 +49,9 @@ in stateVersion = mkOption { type = types.str; - default = cfg.release; + # Deliberately no default, as automatically upgrading the stateVersion can + # lead systems to stop working. + example = cfg.release; description = '' Every once in a while, a new NixOS release may change configuration defaults in a way incompatible with stateful From b6ff51e18cd328dcef5f0c7f4095d6b452809eb1 Mon Sep 17 00:00:00 2001 From: Aristid Breitkreuz Date: Tue, 23 Jul 2019 22:44:34 +0200 Subject: [PATCH 2/3] attempt to fix nixos tests (crude first version) --- nixos/lib/testing.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/lib/testing.nix b/nixos/lib/testing.nix index 7670687710363..e33ee8c6ba7d0 100644 --- a/nixos/lib/testing.nix +++ b/nixos/lib/testing.nix @@ -188,6 +188,7 @@ in rec { networking.hostName = "client"; nix.readOnlyStore = false; virtualisation.writableStore = false; + system.stateVersion = "19.09"; # TODO: determine automatically } ]; From 548d4273e419d30577f75b423c0322b055bc73ba Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 1 Aug 2019 16:29:41 +0200 Subject: [PATCH 3/3] nixos/misc: Improve stateVersion description --- nixos/modules/misc/version.nix | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index 2e4a176f037a6..54009f214ac83 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -53,15 +53,16 @@ in # lead systems to stop working. example = cfg.release; description = '' - 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 can set the - value of this option to the NixOS release with which you want - to be compatible. The effect is that NixOS will option - defaults corresponding to the specified release (such as using - an older version of PostgreSQL). + This option exists to prevent breakage for NixOS modules that depend on + state which can't be controlled by them. The value of this option + represents the initial NixOS version installed, and should + therefore not be ever changed unless you make sure to run all + necessary migrations yourself. By fixing this value, NixOS modules can + know what version your state is in, such that they can make incompatible + changes for new installations, without breaking the module for all + existing installations. For example this is used in the postgresql + module, where a new module version uses a newer postgresql version which + can't read the databases of older versions. ''; };