Commit c0f963a3 authored by Linus Heckemann's avatar Linus Heckemann
Browse files

boot.initrd.services.swraid -> boot.swraid

Since the option affects both stage-1 and stage-2, it does not make
sense to keep it within the boot.initrd namespace.
parent 0b277bcc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@

- The Caddy module gained a new option named `services.caddy.enableReload` which is enabled by default. It allows reloading the service instead of restarting it, if only a config file has changed. This option must be disabled if you have turned off the [Caddy admin API](https://caddyserver.com/docs/caddyfile/options#admin). If you keep this option enabled, you should consider setting [`grace_period`](https://caddyserver.com/docs/caddyfile/options#grace-period) to a non-infinite value to prevent Caddy from delaying the reload indefinitely.

- mdraid support is now optional. This reduces initramfs size and prevents automatic import of software RAID pools, which may not be desired. It is disabled by default in new configurations (determined by `stateVersion`), but the appropriate settings will be generated by `nixos-generate-config` when installing to a software RAID device, so the standard installation procedure should be unaffected.
- mdraid support is now optional. This reduces initramfs size and prevents the potentially undesired automatic detection and activation of software RAID pools. It is disabled by default in new configurations (determined by `stateVersion`), but the appropriate settings will be generated by `nixos-generate-config` when installing to a software RAID device, so the standard installation procedure should be unaffected. If you have custom configs relying on mdraid, ensure that you use `stateVersion` correctly or set `boot.swraid.enable` manually.

## Other Notable Changes {#sec-release-23.11-notable-changes}

+1 −1
Original line number Diff line number Diff line
@@ -534,7 +534,7 @@ EOF
    }
}
if ($useSwraid) {
    push @attrs, "boot.initrd.services.swraid.enable = true;\n\n";
    push @attrs, "boot.swraid.enable = true;\n\n";
}


+1 −3
Original line number Diff line number Diff line
@@ -106,9 +106,7 @@ with lib;
        systemdStage1Network
      ];

    boot.initrd.services = {
      swraid.enable = true;
    };
    boot.swraid.enable = true;

    # Show all debug messages from the kernel but don't log refused packets
    # because we have the firewall enabled. This makes installs from the
+1 −4
Original line number Diff line number Diff line
@@ -354,9 +354,6 @@ let
      [ { object = bootStage1;
          symlink = "/init";
        }
        { object = pkgs.writeText "mdadm.conf" config.boot.initrd.services.swraid.mdadmConf;
          symlink = "/etc/mdadm.conf";
        }
        { object = pkgs.runCommand "initrd-kmod-blacklist-ubuntu" {
              src = "${pkgs.kmod-blacklist-ubuntu}/modprobe.conf";
              preferLocalBuild = true;
@@ -727,6 +724,6 @@ in
  };

  imports = [
    (mkRenamedOptionModule [ "boot" "initrd" "mdadmConf" ] [ "boot" "initrd" "services" "swraid" "mdadmConf" ])
    (mkRenamedOptionModule [ "boot" "initrd" "mdadmConf" ] [ "boot" "swraid" "mdadmConf" ])
  ];
}
+29 −15
Original line number Diff line number Diff line
{ config, pkgs, lib, ... }: let

  cfg = config.boot.initrd.services.swraid;
  cfg = config.boot.swraid;

in {

  options.boot.initrd.services.swraid = {
  options.boot.swraid = {
    enable = lib.mkEnableOption (lib.mdDoc "swraid support using mdadm") // {
      description = lib.mdDoc ''
        Whether to enable swraid support using mdadm.
        Whether to enable support for Linux MD RAID arrays.

        When this is enabled, mdadm will be added to the system path,
        and MD RAID arrays will be detected and activated
        automatically, both in stage-1 (initramfs) and in stage-2 (the
        final NixOS system).

        This should be enabled if you want to be able to access and/or
        boot from MD RAID arrays. {command}`nixos-generate-config`
        should detect it correctly in the standard installation
        procedure.
      '';
      default = lib.versionOlder config.system.stateVersion "23.11";
      defaultText = lib.mdDoc "`true` if stateVersion is older than 23.11";
    };

    mdadmConf = lib.mkOption {
      description = lib.mdDoc "Contents of {file}`/etc/mdadm.conf` in initrd.";
      description = lib.mdDoc "Contents of {file}`/etc/mdadm.conf`.";
      type = lib.types.lines;
      default = "";
    };
@@ -27,13 +37,16 @@ in {

    systemd.packages = [ pkgs.mdadm ];

    boot.initrd.availableKernelModules = [ "md_mod" "raid0" "raid1" "raid10" "raid456" ];
    boot.initrd = {
      availableKernelModules = [ "md_mod" "raid0" "raid1" "raid10" "raid456" ];

    boot.initrd.extraUdevRulesCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
      extraUdevRulesCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
        cp -v ${pkgs.mdadm}/lib/udev/rules.d/*.rules $out/
      '';

    boot.initrd.systemd = {
      extraFiles."/etc/mdadm.conf".source = pkgs.writeText "mdadm.conf" config.boot.swraid.mdadmConf;

      systemd = {
        contents."/etc/mdadm.conf" = lib.mkIf (cfg.mdadmConf != "") {
          text = cfg.mdadmConf;
        };
@@ -42,6 +55,7 @@ in {
        initrdBin = [ pkgs.mdadm ];
      };

    boot.initrd.services.udev.packages = [ pkgs.mdadm ];
      services.udev.packages = [ pkgs.mdadm ];
    };
  };
}
Loading