summary refs log tree commit diff
path: root/nixos/modules/tasks
diff options
context:
space:
mode:
authorChristian Theune <ct@flyingcircus.io>2023-09-16 12:19:19 +0200
committerGitHub <noreply@github.com>2023-09-16 12:19:19 +0200
commit697312fb824243bd7bf82d2a3836a11292614109 (patch)
treec0e2ba3b0c1e3a98500049a6dce6df588b7ff515 /nixos/modules/tasks
parent5dd9b36eac3dc4131714ce5891362e680436e31e (diff)
downloadnixpkgs-697312fb824243bd7bf82d2a3836a11292614109.tar
nixpkgs-697312fb824243bd7bf82d2a3836a11292614109.tar.gz
nixpkgs-697312fb824243bd7bf82d2a3836a11292614109.tar.bz2
nixpkgs-697312fb824243bd7bf82d2a3836a11292614109.tar.lz
nixpkgs-697312fb824243bd7bf82d2a3836a11292614109.tar.xz
nixpkgs-697312fb824243bd7bf82d2a3836a11292614109.tar.zst
nixpkgs-697312fb824243bd7bf82d2a3836a11292614109.zip
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
Diffstat (limited to 'nixos/modules/tasks')
-rw-r--r--nixos/modules/tasks/swraid.nix9
1 files changed, 7 insertions, 2 deletions
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 ];