diff options
author | Janne Heß <janne@hess.ooo> | 2022-04-14 17:56:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-14 17:56:36 +0200 |
commit | 289f38a65b4a9cbd06131d7a58eeb6aefb27daf8 (patch) | |
tree | 57014cc8af5b42ac2c08a8b02e5a0ba36bc05d43 /nixos/modules/system | |
parent | cb80b946a4eecc7f3ed59c3cceb5ef6cb23c7d86 (diff) | |
parent | dda7e9e3ee801d9fbe0cc4d0b3dde024966bc8ee (diff) | |
download | nixpkgs-289f38a65b4a9cbd06131d7a58eeb6aefb27daf8.tar nixpkgs-289f38a65b4a9cbd06131d7a58eeb6aefb27daf8.tar.gz nixpkgs-289f38a65b4a9cbd06131d7a58eeb6aefb27daf8.tar.bz2 nixpkgs-289f38a65b4a9cbd06131d7a58eeb6aefb27daf8.tar.lz nixpkgs-289f38a65b4a9cbd06131d7a58eeb6aefb27daf8.tar.xz nixpkgs-289f38a65b4a9cbd06131d7a58eeb6aefb27daf8.tar.zst nixpkgs-289f38a65b4a9cbd06131d7a58eeb6aefb27daf8.zip |
Merge pull request #168301 from helsinki-systems/feat/systemd-stage-1-mdadm
nixos/stage-1-systemd: Add mdraid support (+ test)
Diffstat (limited to 'nixos/modules/system')
-rw-r--r-- | nixos/modules/system/boot/stage-1.nix | 15 | ||||
-rw-r--r-- | nixos/modules/system/boot/systemd/initrd-mdraid.nix | 32 |
2 files changed, 37 insertions, 10 deletions
diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index 04753a6767d..3ab873604d3 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -355,7 +355,7 @@ let [ { object = bootStage1; symlink = "/init"; } - { object = pkgs.writeText "mdadm.conf" config.boot.initrd.mdadmConf; + { object = pkgs.writeText "mdadm.conf" config.boot.initrd.services.mdraid.mdadmConf; symlink = "/etc/mdadm.conf"; } { object = pkgs.runCommand "initrd-kmod-blacklist-ubuntu" { @@ -505,14 +505,6 @@ in ''; }; - boot.initrd.mdadmConf = mkOption { - default = ""; - type = types.lines; - description = '' - Contents of <filename>/etc/mdadm.conf</filename> in stage 1. - ''; - }; - boot.initrd.preLVMCommands = mkOption { default = ""; type = types.lines; @@ -736,6 +728,9 @@ in ]; boot.initrd.supportedFilesystems = map (fs: fs.fsType) fileSystems; - }; + + imports = [ + (mkRenamedOptionModule [ "boot" "initrd" "mdadmConf" ] [ "boot" "initrd" "services" "mdraid" "mdadmConf" ]) + ]; } diff --git a/nixos/modules/system/boot/systemd/initrd-mdraid.nix b/nixos/modules/system/boot/systemd/initrd-mdraid.nix new file mode 100644 index 00000000000..b30f2e083fd --- /dev/null +++ b/nixos/modules/system/boot/systemd/initrd-mdraid.nix @@ -0,0 +1,32 @@ +{ config, pkgs, lib, ... }: let + + cfg = config.boot.initrd.services.mdraid; + +in { + options.boot.initrd.services.mdraid = { + enable = (lib.mkEnableOption "mdraid support in initrd") // { + visible = false; + }; + + mdadmConf = lib.mkOption { + description = "Contents of <filename>/etc/mdadm.conf</filename> in initrd."; + type = lib.types.lines; + default = ""; + }; + }; + + config = lib.mkIf (config.boot.initrd.systemd.enable && cfg.enable) { + boot.initrd.systemd = { + contents."/etc/mdadm.conf" = lib.mkIf (cfg.mdadmConf != "") { + text = cfg.mdadmConf; + }; + + initrdBin = [ pkgs.mdadm ]; + }; + + boot.initrd.services.udev.packages = [ pkgs.mdadm ]; + boot.initrd.systemd.packages = [ pkgs.mdadm ]; + + boot.kernelModules = [ "dm-raid" ]; + }; +} |