Merge pull request #263744 from K900/stateversion-docs

treewide: rewrite stateVersion docs (again), clean up some stateVersion usages (again)
This commit is contained in:
K900 2023-10-29 16:25:48 +03:00 committed by GitHub
commit 220241421f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 68 additions and 43 deletions

View file

@ -21,7 +21,6 @@ in
virtualisation.azureImage.diskSize = 2500;
system.stateVersion = "20.03";
boot.kernelPackages = pkgs.linuxPackages_latest;
# test user doesn't have a password

View file

@ -2,13 +2,13 @@
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, lib, ... }:
{ config, pkgs, lib, modulesPath, ... }:
{
imports =
[
# Include the default lxd configuration.
../../../modules/virtualisation/lxc-container.nix
"${modulesPath}/modules/virtualisation/lxc-container.nix"
# Include the container-specific autogenerated configuration.
./lxd.nix
];
@ -16,5 +16,5 @@
networking.useDHCP = false;
networking.interfaces.eth0.useDHCP = true;
system.stateVersion = "21.05"; # Did you read the comment?
system.stateVersion = "@stateVersion@"; # Did you read the comment?
}

View file

@ -13,11 +13,15 @@
};
# copy the config for nixos-rebuild
system.activationScripts.config = ''
system.activationScripts.config = let
config = pkgs.substituteAll {
src = ./lxd-container-image-inner.nix;
stateVersion = lib.trivial.release;
};
in ''
if [ ! -e /etc/nixos/configuration.nix ]; then
mkdir -p /etc/nixos
cat ${./lxd-container-image-inner.nix} > /etc/nixos/configuration.nix
${lib.getExe pkgs.gnused} 's|../../../modules/virtualisation/lxc-container.nix|<nixpkgs/nixos/modules/virtualisation/lxc-container.nix>|g' -i /etc/nixos/configuration.nix
cp ${config} /etc/nixos/configuration.nix
fi
'';

View file

@ -2,13 +2,13 @@
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, lib, ... }:
{ config, pkgs, lib, modulesPath, ... }:
{
imports =
[
# Include the default lxd configuration.
../../../modules/virtualisation/lxd-virtual-machine.nix
"${modulesPath}/virtualisation/lxd-virtual-machine.nix"
# Include the container-specific autogenerated configuration.
./lxd.nix
];
@ -16,5 +16,5 @@
networking.useDHCP = false;
networking.interfaces.eth0.useDHCP = true;
system.stateVersion = "23.05"; # Did you read the comment?
system.stateVersion = "@stateVersion@"; # Did you read the comment?
}

View file

@ -13,11 +13,15 @@
};
# copy the config for nixos-rebuild
system.activationScripts.config = ''
system.activationScripts.config = let
config = pkgs.substituteAll {
src = ./lxd-virtual-machine-image-inner.nix;
stateVersion = lib.trivial.release;
};
in ''
if [ ! -e /etc/nixos/configuration.nix ]; then
mkdir -p /etc/nixos
cat ${./lxd-virtual-machine-image-inner.nix} > /etc/nixos/configuration.nix
${lib.getExe pkgs.gnused} 's|../../../modules/virtualisation/lxd-virtual-machine.nix|<nixpkgs/nixos/modules/virtualisation/lxd-virtual-machine.nix>|g' -i /etc/nixos/configuration.nix
cp ${config} /etc/nixos/configuration.nix
fi
'';

View file

@ -224,12 +224,22 @@ in
# accidentally delete configuration.nix.
# system.copySystemConfiguration = true;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It's perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
#
# Most users should NEVER change this value after the initial install, for any reason,
# even if you've upgraded your system to a new NixOS release.
#
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
# so changing it will NOT upgrade your system.
#
# This value being lower than the current NixOS release does NOT mean your system is
# out of date, out of support, or vulnerable.
#
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
# and migrated your data accordingly.
#
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "${config.system.nixos.release}"; # Did you read the comment?
}

View file

@ -21,7 +21,7 @@ with lib;
services.xserver.videoDrivers = mkOverride 40 [ "virtualbox" "vmware" "cirrus" "vesa" "modesetting" ];
powerManagement.enable = false;
system.stateVersion = mkDefault "18.03";
system.stateVersion = lib.mkDefault lib.trivial.release;
installer.cloneConfigExtra = ''
# Let demo build as a trusted user.

View file

@ -121,22 +121,32 @@ in
default = cfg.release;
defaultText = literalExpression "config.${opt.release}";
description = lib.mdDoc ''
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 should set the
value of this option to the NixOS release with which you want
to be compatible. The effect is that NixOS will use
defaults corresponding to the specified release (such as using
an older version of PostgreSQL).
Its perfectly fine and recommended to leave this value at the
release version of the first install of this system.
Changing this option will not upgrade your system. In fact it
is meant to stay constant exactly when you upgrade your system.
You should only bump this option, if you are sure that you can
or have migrated all state on your system which is affected
by this option.
This option defines the first version of NixOS you have installed on this particular machine,
and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
For example, if NixOS version XX.YY ships with AwesomeDB version N by default, and is then
upgraded to version XX.YY+1, which ships AwesomeDB version N+1, the existing databases
may no longer be compatible, causing applications to fail, or even leading to data loss.
The `stateVersion` mechanism avoids this situation by making the default version of such packages
conditional on the first version of NixOS you've installed (encoded in `stateVersion`), instead of
simply always using the latest one.
Note that this generally only affects applications that can't upgrade their data automatically -
applications and services supporting automatic migrations will remain on latest versions when
you upgrade.
Most users should **never** change this value after the initial install, for any reason,
even if you've upgraded your system to a new NixOS release.
This value does **not** affect the Nixpkgs version your packages and OS are pulled from,
so changing it will **not** upgrade your system.
This value being lower than the current NixOS release does **not** mean your system is
out of date, out of support, or vulnerable.
Do **not** change this value unless you have manually inspected all the changes it would
make to your configuration, and migrated your data accordingly.
'';
};

View file

@ -754,7 +754,7 @@ in
{ services.postgresql.enable = true;
services.postgresql.package = pkgs.postgresql_14;
system.stateVersion = "21.05";
system.stateVersion = "${lib.trivial.release}";
};
};
}
@ -906,4 +906,6 @@ in
"tun"
];
});
meta.buildDocsInSandbox = false;
}

View file

@ -398,7 +398,7 @@ in rec {
modules = singleton ({ ... }:
{ fileSystems."/".device = mkDefault "/dev/sda1";
boot.loader.grub.device = mkDefault "/dev/sda";
system.stateVersion = mkDefault "18.03";
system.stateVersion = mkDefault lib.trivial.release;
});
}).config.system.build.toplevel;
preferLocalBuild = true;

View file

@ -21,9 +21,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
modules = lib.singleton {
nixpkgs = { inherit (config.nixpkgs) localSystem; };
containers.foo.config = {
system.stateVersion = "18.03";
};
containers.foo.config = {};
};
# The system is inherited from the host above.

View file

@ -37,8 +37,6 @@ in {
"d /var/lib/nextcloud-data 0750 nextcloud nginx - -"
];
system.stateVersion = "22.11"; # stateVersion >=21.11 to make sure that we use OpenSSL3
services.nextcloud = {
enable = true;
datadir = "/var/lib/nextcloud-data";