From 697312fb824243bd7bf82d2a3836a11292614109 Mon Sep 17 00:00:00 2001 From: Christian Theune Date: Sat, 16 Sep 2023 12:19:19 +0200 Subject: nixos/swraid: only warn if swraid was explicitly enabled (#255426) The default just recently changed in 23.11. Users that had swraid enabled implicitly by NixOS in previous releases got surprised by warnings even though they do not actually use software RAID. Fixes #254807 --- nixos/modules/tasks/swraid.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'nixos/modules/tasks') diff --git a/nixos/modules/tasks/swraid.nix b/nixos/modules/tasks/swraid.nix index 1174187062d..61b3682e0f6 100644 --- a/nixos/modules/tasks/swraid.nix +++ b/nixos/modules/tasks/swraid.nix @@ -4,6 +4,11 @@ mdadm_conf = config.environment.etc."mdadm.conf"; + enable_implicitly_for_old_state_versions = lib.versionOlder config.system.stateVersion "23.11"; + + minimum_config_is_set = config_text: + (builtins.match ".*(MAILADDR|PROGRAM).*" mdadm_conf.text) != null; + in { imports = [ (lib.mkRenamedOptionModule [ "boot" "initrd" "services" "swraid" "enable" ] [ "boot" "swraid" "enable" ]) @@ -26,7 +31,7 @@ in { should detect it correctly in the standard installation procedure. ''; - default = lib.versionOlder config.system.stateVersion "23.11"; + default = enable_implicitly_for_old_state_versions; defaultText = lib.mdDoc "`true` if stateVersion is older than 23.11"; }; @@ -39,7 +44,7 @@ in { config = lib.mkIf cfg.enable { warnings = lib.mkIf - ((builtins.match ".*(MAILADDR|PROGRAM).*" mdadm_conf.text) == null) + ( !enable_implicitly_for_old_state_versions && !minimum_config_is_set mdadm_conf) [ "mdadm: Neither MAILADDR nor PROGRAM has been set. This will cause the `mdmon` service to crash." ]; environment.systemPackages = [ pkgs.mdadm ]; -- cgit 1.4.1