system/state-version: init
This commit is contained in:
parent
44cf0004f4
commit
c61de2d262
48
nixos/modules/system/state-version.nix
Normal file
48
nixos/modules/system/state-version.nix
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
# Portions of this file are sourced from
|
||||||
|
# https://github.com/linyinfeng/dotfiles/blob/b618b0fd16fb9c79ab7199ed51c4c0f98a392cea/nixos/modules/system/state-version.nix
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
options,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.system;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
system.targetStateVersion = mkOption {
|
||||||
|
inherit (options.system.stateVersion) type;
|
||||||
|
default = config.system.stateVersion;
|
||||||
|
description = ''
|
||||||
|
System is going to be upgraded to the targetStateVersion.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
system.pendingStateVersionUpgrade = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = cfg.stateVersion != cfg.targetStateVersion;
|
||||||
|
readOnly = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
specialisation = mkIf cfg.pendingStateVersionUpgrade {
|
||||||
|
target-state-version = {
|
||||||
|
configuration = {
|
||||||
|
system.stateVersion = mkForce targetStateVersion;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
warnings = mkIf cfg.pendingStateVersionUpgrade [
|
||||||
|
''
|
||||||
|
|
||||||
|
host: ${config.networking.hostName}
|
||||||
|
pending stateVersion upgrade from ${cfg.stateVersion} to ${cfg.targetStateVersion}
|
||||||
|
release notes: https://nixos.org/manual/nixos/stable/release-notes.html#sec-release-${cfg.targetStateVersion}
|
||||||
|
|
||||||
|
''
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue