summary refs log tree commit diff
path: root/nixos/modules/system/boot/stage-1.nix
diff options
context:
space:
mode:
authorMichael Brantley <brantley@floxdev.com>2021-03-11 06:46:31 -0500
committerMichael Brantley <brantley@storehouseqa1.nyc.deshaw.com>2021-10-08 09:47:38 -0400
commit121cfd1998e50f55d48502c0fc80cb7611f7e699 (patch)
tree1aae4859bff293adb220f05044d7b69c6c2a6629 /nixos/modules/system/boot/stage-1.nix
parentc344317f186ce75be82d0a5509df64e68024e38c (diff)
downloadnixpkgs-121cfd1998e50f55d48502c0fc80cb7611f7e699.tar
nixpkgs-121cfd1998e50f55d48502c0fc80cb7611f7e699.tar.gz
nixpkgs-121cfd1998e50f55d48502c0fc80cb7611f7e699.tar.bz2
nixpkgs-121cfd1998e50f55d48502c0fc80cb7611f7e699.tar.lz
nixpkgs-121cfd1998e50f55d48502c0fc80cb7611f7e699.tar.xz
nixpkgs-121cfd1998e50f55d48502c0fc80cb7611f7e699.tar.zst
nixpkgs-121cfd1998e50f55d48502c0fc80cb7611f7e699.zip
nixos/multipath: add multipath module
The multipath-tools package had existed in Nixpkgs for some time but
without a nixos module to configure/drive it. This module provides
attributes to drive the majority of multipath configuration options
and is being successfully used in stage-1 and stage-2 boot to mount
/nix from a multipath-serviced iSCSI volume.

Credit goes to @grahamc for early contributions to the module and
authoring the NixOS module test.
Diffstat (limited to 'nixos/modules/system/boot/stage-1.nix')
-rw-r--r--nixos/modules/system/boot/stage-1.nix24
1 files changed, 24 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix
index be0d0893626..adbed9d8d58 100644
--- a/nixos/modules/system/boot/stage-1.nix
+++ b/nixos/modules/system/boot/stage-1.nix
@@ -137,6 +137,14 @@ let
         copy_bin_and_libs ${pkgs.e2fsprogs}/sbin/resize2fs
       ''}
 
+      # Copy multipath.
+      ${optionalString config.services.multipath.enable ''
+        copy_bin_and_libs ${config.services.multipath.package}/bin/multipath
+        copy_bin_and_libs ${config.services.multipath.package}/bin/multipathd
+        # Copy lib/multipath manually.
+        cp -rpv ${config.services.multipath.package}/lib/multipath $out/lib
+      ''}
+
       # Copy secrets if needed.
       #
       # TODO: move out to a separate script; see #85000.
@@ -199,6 +207,10 @@ let
       $out/bin/dmsetup --version 2>&1 | tee -a log | grep -q "version:"
       LVM_SYSTEM_DIR=$out $out/bin/lvm version 2>&1 | tee -a log | grep -q "LVM"
       $out/bin/mdadm --version
+      ${optionalString config.services.multipath.enable ''
+        ($out/bin/multipath || true) 2>&1 | grep -q 'need to be root'
+        ($out/bin/multipathd || true) 2>&1 | grep -q 'need to be root'
+      ''}
 
       ${config.boot.initrd.extraUtilsCommandsTest}
       fi
@@ -338,6 +350,18 @@ let
         { object = pkgs.kmod-debian-aliases;
           symlink = "/etc/modprobe.d/debian.conf";
         }
+      ] ++ lib.optionals config.services.multipath.enable [
+        { object = pkgs.runCommand "multipath.conf" {
+              src = config.environment.etc."multipath.conf".text;
+              preferLocalBuild = true;
+            } ''
+              target=$out
+              printf "$src" > $out
+              substituteInPlace $out \
+                --replace ${config.services.multipath.package}/lib ${extraUtils}/lib
+            '';
+          symlink = "/etc/multipath.conf";
+        }
       ] ++ (lib.mapAttrsToList
         (symlink: options:
           {