1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

Merge pull request #1075 from emilazy/push-oszxxzpyppzm

version: make `system.stateVersion` mandatory
This commit is contained in:
Emily 2024-09-13 01:53:33 +01:00 committed by GitHub
commit 21fe31f264
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 35 additions and 11 deletions

View file

@ -5,8 +5,6 @@ with lib;
let let
cfg = config.system; cfg = config.system;
defaultStateVersion = options.system.stateVersion.default;
# Based on `lib.trivial.revisionWithDefault` from nixpkgs. # Based on `lib.trivial.revisionWithDefault` from nixpkgs.
gitRevision = path: gitRevision = path:
if pathIsGitRepo "${path}/.git" if pathIsGitRepo "${path}/.git"
@ -34,8 +32,9 @@ in
{ {
options = { options = {
system.stateVersion = mkOption { system.stateVersion = mkOption {
type = types.int; type = types.ints.between 1 config.system.maxStateVersion;
default = 5; # TODO: Remove this default and the assertion below.
default = config.system.maxStateVersion;
description = '' description = ''
Every once in a while, a new NixOS release may change Every once in a while, a new NixOS release may change
configuration defaults in a way incompatible with stateful 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 { system.darwinLabel = mkOption {
type = types.str; type = types.str;
description = "Label to be used in the names of generated outputs."; description = "Label to be used in the names of generated outputs.";
@ -121,9 +126,22 @@ in
# documentation is not reprocessed on every commit # documentation is not reprocessed on every commit
system.darwinLabel = mkDefault "${cfg.nixpkgsVersion}+${cfg.darwinVersion}"; system.darwinLabel = mkDefault "${cfg.nixpkgsVersion}+${cfg.darwinVersion}";
assertions = [ { assertions = [
assertion = cfg.stateVersion <= defaultStateVersion; {
message = "system.stateVersion = ${toString cfg.stateVersion}; is not a valid value"; 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
backwardsincompatible 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};
'';
}
];
}; };
} }

View file

@ -40,6 +40,8 @@ let
}; };
config = { config = {
system.stateVersion = lib.mkDefault config.system.maxStateVersion;
system.build.run-test = pkgs.runCommand "darwin-test-${testName}" system.build.run-test = pkgs.runCommand "darwin-test-${testName}"
{ allowSubstitutes = false; preferLocalBuild = true; } { allowSubstitutes = false; preferLocalBuild = true; }
'' ''
@ -71,6 +73,10 @@ let
nano emacs vim; nano emacs vim;
}; };
manual = buildFromConfig ({ lib, config, ... }: {
system.stateVersion = lib.mkDefault config.system.maxStateVersion;
}) (config: config.system.build.manual);
jobs = { jobs = {
unstable = pkgs.releaseTools.aggregate { unstable = pkgs.releaseTools.aggregate {
@ -92,9 +98,9 @@ let
meta.description = "Release-critical builds for the darwin channel"; meta.description = "Release-critical builds for the darwin channel";
}; };
manualHTML = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualHTML); manualHTML = manual.manualHTML;
manpages = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manpages); manpages = manual.manpages;
options = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.optionsJSON); options = manual.optionsJSON;
examples.hydra = makeSystem ./modules/examples/hydra.nix; examples.hydra = makeSystem ./modules/examples/hydra.nix;
examples.lnl = makeSystem ./modules/examples/lnl.nix; examples.lnl = makeSystem ./modules/examples/lnl.nix;