1{ pkgs, ... }:
2
3{
4
5 environment.systemPackages = [ pkgs.mdadm ];
6
7 services.udev.packages = [ pkgs.mdadm ];
8
9 boot.initrd.availableKernelModules = [ "md_mod" "raid0" "raid1" "raid10" "raid456" ];
10
11 boot.initrd.extraUdevRulesCommands = ''
12 cp -v ${pkgs.mdadm}/lib/udev/rules.d/*.rules $out/
13 '';
14
15 systemd.services.mdadm-shutdown = {
16 wantedBy = [ "final.target"];
17 after = [ "umount.target" ];
18
19 unitConfig = {
20 DefaultDependencies = false;
21 };
22
23 serviceConfig = {
24 Type = "oneshot";
25 ExecStart = ''${pkgs.mdadm}/bin/mdadm --wait-clean --scan'';
26 };
27 };
28
29 systemd.services."mdmon@" = {
30 description = "MD Metadata Monitor on /dev/%I";
31
32 unitConfig.DefaultDependencies = false;
33
34 serviceConfig = {
35 Type = "forking";
36 Environment = "IMSM_NO_PLATFORM=1";
37 ExecStart = ''${pkgs.mdadm}/bin/mdmon --offroot --takeover %I'';
38 KillMode = "none";
39 };
40 };
41
42 systemd.services."mdadm-grow-continue@" = {
43 description = "Manage MD Reshape on /dev/%I";
44
45 unitConfig.DefaultDependencies = false;
46
47 serviceConfig = {
48 ExecStart = ''${pkgs.mdadm}/bin/mdadm --grow --continue /dev/%I'';
49 StandardInput = "null";
50 StandardOutput = "null";
51 StandardError = "null";
52 KillMode = "none";
53 };
54 };
55
56}