diff options
| author | Emily <vcs@emily.moe> | 2024-09-13 01:53:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-13 01:53:33 +0100 |
| commit | 21fe31f26473c180390cfa81e3ea81aca0204c80 (patch) | |
| tree | 5af84f12b69592db3808b3357f7fa3f524b2b1c3 /modules | |
| parent | 122ff62d68c9068706393001d5884b66bc0067c4 (diff) | |
| parent | 04e3cfc822568d354b540a3207121af27b699057 (diff) | |
Merge pull request #1075 from emilazy/push-oszxxzpyppzm
version: make `system.stateVersion` mandatory
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/system/version.nix | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/modules/system/version.nix b/modules/system/version.nix index df8b7a0..826ad35 100644 --- a/modules/system/version.nix +++ b/modules/system/version.nix @@ -5,8 +5,6 @@ with lib; let cfg = config.system; - defaultStateVersion = options.system.stateVersion.default; - # Based on `lib.trivial.revisionWithDefault` from nixpkgs. gitRevision = path: if pathIsGitRepo "${path}/.git" @@ -34,8 +32,9 @@ in { options = { system.stateVersion = mkOption { - type = types.int; - default = 5; + type = types.ints.between 1 config.system.maxStateVersion; + # TODO: Remove this default and the assertion below. + default = config.system.maxStateVersion; description = '' Every once in a while, a new NixOS release may change configuration defaults in a way incompatible with stateful @@ -49,6 +48,12 @@ in ''; }; + system.maxStateVersion = mkOption { + internal = true; + type = types.int; + default = 5; + }; + system.darwinLabel = mkOption { type = types.str; description = "Label to be used in the names of generated outputs."; @@ -121,9 +126,22 @@ in # documentation is not reprocessed on every commit system.darwinLabel = mkDefault "${cfg.nixpkgsVersion}+${cfg.darwinVersion}"; - assertions = [ { - assertion = cfg.stateVersion <= defaultStateVersion; - message = "system.stateVersion = ${toString cfg.stateVersion}; is not a valid value"; - } ]; + assertions = [ + { + assertion = options.system.stateVersion.highestPrio != (lib.mkOptionDefault { }).priority; + message = '' + The `system.stateVersion` option is not defined in your + nix-darwin configuration. The value is used to conditionalize + backwards‐incompatible changes in default settings. You should + usually set this once when installing nix-darwin on a new system + and then never change it (at least without reading all the relevant + entries in the changelog using `darwin-rebuild changelog`). + + You can use the current value for new installations as follows: + + system.stateVersion = ${toString config.system.maxStateVersion}; + ''; + } + ]; }; } |
