diff --git a/stylix/darwin/default.nix b/stylix/darwin/default.nix index 947aaca8..a966c273 100644 --- a/stylix/darwin/default.nix +++ b/stylix/darwin/default.nix @@ -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. + '' + ]; } diff --git a/stylix/hm/default.nix b/stylix/hm/default.nix index 0fd7f84a..0df2301b 100644 --- a/stylix/hm/default.nix +++ b/stylix/hm/default.nix @@ -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. + '' + ]; } diff --git a/stylix/nixos/default.nix b/stylix/nixos/default.nix index 05ce0ff5..32180f3f 100644 --- a/stylix/nixos/default.nix +++ b/stylix/nixos/default.nix @@ -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. + '' + ]; } diff --git a/stylix/release.nix b/stylix/release.nix new file mode 100644 index 00000000..88aa6dd2 --- /dev/null +++ b/stylix/release.nix @@ -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; + }; + }; +}