stylix: add version checks (#924)

Basic release version checks for NixOS, Home Manager, nix-darwin, and Stylix.

Fixes #379

Co-authored-by: Daniel Thwaites <danth@danth.me>
This commit is contained in:
Flameopathic 2025-03-10 11:36:48 -04:00 committed by GitHub
parent 6c42dc31ef
commit fc5acae54b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 95 additions and 3 deletions

View file

@ -1,5 +1,5 @@
inputs:
{ lib, ... }:
{ lib, config, ... }:
# Imported modules which define new options must use an absolute path based
# on ${inputs.self}, otherwise those options will not appear in the generated
@ -18,5 +18,28 @@ in
"${inputs.self}/stylix/palette.nix"
"${inputs.self}/stylix/pixel.nix"
"${inputs.self}/stylix/target.nix"
"${inputs.self}/stylix/release.nix"
] ++ autoload;
config.warnings =
lib.mkIf
(
config.stylix.enable
&& config.stylix.enableReleaseChecks
&& (config.stylix.release != config.system.darwin.release)
)
[
''
You are using different Stylix and nix-darwin versions. This is
likely to cause errors and unexpected behavior. It is highly
recommended that you use a version of Stylix that matches your chosen
version of nix-darwin.
If you are willing to accept the risks that come with using
mismatched versions, you may disable this warning by adding
stylix.enableReleaseChecks = false;
to your configuration.
''
];
}

View file

@ -1,5 +1,5 @@
inputs:
{ lib, ... }:
{ lib, config, ... }:
# Imported modules which define new options must use an absolute path based
# on ${inputs.self}, otherwise those options will not appear in the generated
@ -21,5 +21,28 @@ in
"${inputs.self}/stylix/palette.nix"
"${inputs.self}/stylix/pixel.nix"
"${inputs.self}/stylix/target.nix"
"${inputs.self}/stylix/release.nix"
] ++ autoload;
config.warnings =
lib.mkIf
(
config.stylix.enable
&& config.stylix.enableReleaseChecks
&& (config.stylix.release != config.home.version.release)
)
[
''
You are using different Stylix and Home Manager versions. This is
likely to cause errors and unexpected behavior. It is highly
recommended that you use a version of Stylix that matches your chosen
version of Home Manager.
If you are willing to accept the risks that come with using
mismatched versions, you may disable this warning by adding
stylix.enableReleaseChecks = false;
to your configuration.
''
];
}

View file

@ -1,5 +1,5 @@
inputs:
{ lib, ... }:
{ lib, config, ... }:
# Imported modules which define new options must use an absolute path based
# on ${inputs.self}, otherwise those options will not appear in the generated
@ -20,5 +20,28 @@ in
"${inputs.self}/stylix/palette.nix"
"${inputs.self}/stylix/pixel.nix"
"${inputs.self}/stylix/target.nix"
"${inputs.self}/stylix/release.nix"
] ++ autoload;
config.warnings =
lib.mkIf
(
config.stylix.enable
&& config.stylix.enableReleaseChecks
&& (config.stylix.release != config.system.nixos.release)
)
[
''
You are using different Stylix and NixOS versions. This is
likely to cause errors and unexpected behavior. It is highly
recommended that you use a version of Stylix that matches your chosen
version of NixOS.
If you are willing to accept the risks that come with using
mismatched versions, you may disable this warning by adding
stylix.enableReleaseChecks = false;
to your configuration.
''
];
}

23
stylix/release.nix Normal file
View file

@ -0,0 +1,23 @@
{ lib, ... }:
{
options.stylix = {
release = lib.mkOption {
description = "The version of NixOS that Stylix is built to support";
default = "25.05";
internal = true;
readOnly = true;
};
enableReleaseChecks = lib.mkOption {
description = ''
Whether to check that the Stylix release matches the releases of
NixOS, Home Manager, and nix-darwin. Checks are only performed if the
component in question is used.
If this option is enabled and a mismatch is detected, a warning will be
printed when the user configuration is being built.
'';
type = lib.types.bool;
default = true;
};
};
}