mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 04:43:09 +03:00
Add option system.stateVersion
This option requests compatibility with older NixOS releases with respect to stateful data, in cases where new releases have defaults that might be incompatible with system state of existing NixOS deployments. For instance, if we change the default version of PostgreSQL, existing deployments will break if the new version can't read databases created by the old version. So for example, setting system.stateVersion = "15.07"; requests that options like services.postgresql.package use defaults corresponding to the 15.07 release branch. Note that nixos-generate-config emits this option. (In the future, NixOps may set system.stateVersion to the NixOS release in use when the machine was created.) See also #7939 for another motivating example.
This commit is contained in:
parent
e3a5bca4ae
commit
d166c854b6
@ -544,6 +544,9 @@ $bootLoaderConfig
|
||||
# uid = 1000;
|
||||
# };
|
||||
|
||||
# The NixOS release to be compatible with for stateful data such as databases.
|
||||
system.stateVersion = "@nixosRelease@";
|
||||
|
||||
}
|
||||
EOF
|
||||
} else {
|
||||
|
@ -40,6 +40,7 @@ let
|
||||
src = ./nixos-generate-config.pl;
|
||||
path = [ pkgs.btrfsProgs ];
|
||||
perl = "${pkgs.perl}/bin/perl -I${pkgs.perlPackages.FileSlurp}/lib/perl5/site_perl";
|
||||
inherit (config.system) nixosRelease;
|
||||
};
|
||||
|
||||
nixos-option = makeProg {
|
||||
|
@ -6,12 +6,35 @@ with lib;
|
||||
|
||||
options = {
|
||||
|
||||
system.stateVersion = mkOption {
|
||||
type = types.str;
|
||||
default = config.system.nixosRelease;
|
||||
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).
|
||||
'';
|
||||
};
|
||||
|
||||
system.nixosVersion = mkOption {
|
||||
internal = true;
|
||||
type = types.str;
|
||||
description = "NixOS version.";
|
||||
};
|
||||
|
||||
system.nixosRelease = mkOption {
|
||||
internal = true;
|
||||
type = types.str;
|
||||
default = readFile "${toString pkgs.path}/.version";
|
||||
description = "NixOS release.";
|
||||
};
|
||||
|
||||
system.nixosVersionSuffix = mkOption {
|
||||
internal = true;
|
||||
type = types.str;
|
||||
@ -41,8 +64,7 @@ with lib;
|
||||
|
||||
config = {
|
||||
|
||||
system.nixosVersion =
|
||||
mkDefault (readFile "${toString pkgs.path}/.version" + config.system.nixosVersionSuffix);
|
||||
system.nixosVersion = mkDefault (config.system.nixosRelease + config.system.nixosVersionSuffix);
|
||||
|
||||
system.nixosVersionSuffix =
|
||||
let suffixFile = "${toString pkgs.path}/.version-suffix"; in
|
||||
|
Loading…
Reference in New Issue
Block a user