2022-04-15 17:28:41 +02:00
|
|
|
{ config, pkgs, lib, ... }: let
|
2009-03-06 13:27:30 +01:00
|
|
|
|
2022-04-15 17:28:41 +02:00
|
|
|
cfg = config.boot.initrd.services.swraid;
|
2007-01-11 01:40:28 +01:00
|
|
|
|
2022-04-15 17:28:41 +02:00
|
|
|
in {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2022-04-15 17:28:41 +02:00
|
|
|
options.boot.initrd.services.swraid = {
|
2022-08-29 19:33:50 +02:00
|
|
|
enable = (lib.mkEnableOption (lib.mdDoc "swraid support using mdadm")) // {
|
2022-04-15 17:28:41 +02:00
|
|
|
visible = false; # only has effect when the new stage 1 is in place
|
|
|
|
};
|
2009-12-29 11:04:54 +01:00
|
|
|
|
2022-04-15 17:28:41 +02:00
|
|
|
mdadmConf = lib.mkOption {
|
2022-07-19 15:05:45 +02:00
|
|
|
description = lib.mdDoc "Contents of {file}`/etc/mdadm.conf` in initrd.";
|
2022-04-15 17:28:41 +02:00
|
|
|
type = lib.types.lines;
|
|
|
|
default = "";
|
|
|
|
};
|
|
|
|
};
|
2019-07-25 15:36:16 +02:00
|
|
|
|
2022-04-15 17:28:41 +02:00
|
|
|
config = {
|
|
|
|
environment.systemPackages = [ pkgs.mdadm ];
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2022-04-15 17:28:41 +02:00
|
|
|
services.udev.packages = [ pkgs.mdadm ];
|
2014-11-10 22:08:10 +01:00
|
|
|
|
2022-04-15 17:28:41 +02:00
|
|
|
systemd.packages = [ pkgs.mdadm ];
|
|
|
|
|
|
|
|
boot.initrd.availableKernelModules = lib.mkIf (config.boot.initrd.systemd.enable -> cfg.enable) [ "md_mod" "raid0" "raid1" "raid10" "raid456" ];
|
|
|
|
|
|
|
|
boot.initrd.extraUdevRulesCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
|
|
|
|
cp -v ${pkgs.mdadm}/lib/udev/rules.d/*.rules $out/
|
|
|
|
'';
|
|
|
|
|
|
|
|
boot.initrd.systemd = lib.mkIf cfg.enable {
|
|
|
|
contents."/etc/mdadm.conf" = lib.mkIf (cfg.mdadmConf != "") {
|
|
|
|
text = cfg.mdadmConf;
|
|
|
|
};
|
|
|
|
|
|
|
|
packages = [ pkgs.mdadm ];
|
|
|
|
initrdBin = [ pkgs.mdadm ];
|
|
|
|
};
|
|
|
|
|
|
|
|
boot.initrd.services.udev.packages = lib.mkIf cfg.enable [ pkgs.mdadm ];
|
|
|
|
};
|
2007-01-11 01:40:28 +01:00
|
|
|
}
|