summary refs log tree commit diff
diff options
context:
space:
mode:
authorWill Fancher <elvishjerricco@gmail.com>2023-04-15 03:12:29 -0400
committerWill Fancher <elvishjerricco@gmail.com>2023-04-21 13:05:12 -0400
commit5c46e6f4e3b517418c64f32c9a0e0c874e81ee8b (patch)
treee660ba108fb3190712476f20d7c214d338a8aae9
parent8f9416e9e3526cddc5faeadd5959b29353caf354 (diff)
downloadnixpkgs-5c46e6f4e3b517418c64f32c9a0e0c874e81ee8b.tar
nixpkgs-5c46e6f4e3b517418c64f32c9a0e0c874e81ee8b.tar.gz
nixpkgs-5c46e6f4e3b517418c64f32c9a0e0c874e81ee8b.tar.bz2
nixpkgs-5c46e6f4e3b517418c64f32c9a0e0c874e81ee8b.tar.lz
nixpkgs-5c46e6f4e3b517418c64f32c9a0e0c874e81ee8b.tar.xz
nixpkgs-5c46e6f4e3b517418c64f32c9a0e0c874e81ee8b.tar.zst
nixpkgs-5c46e6f4e3b517418c64f32c9a0e0c874e81ee8b.zip
systemd-stage-1: Add assertions for unsupported options.
-rw-r--r--nixos/modules/services/networking/iscsi/root-initiator.nix4
-rw-r--r--nixos/modules/system/boot/grow-partition.nix5
-rw-r--r--nixos/modules/system/boot/systemd/initrd.nix21
3 files changed, 29 insertions, 1 deletions
diff --git a/nixos/modules/services/networking/iscsi/root-initiator.nix b/nixos/modules/services/networking/iscsi/root-initiator.nix
index 4434fedce1e..895467cc674 100644
--- a/nixos/modules/services/networking/iscsi/root-initiator.nix
+++ b/nixos/modules/services/networking/iscsi/root-initiator.nix
@@ -185,6 +185,10 @@ in
         assertion = cfg.loginAll -> cfg.target == null;
         message = "iSCSI target name is set while login on all portals is enabled.";
       }
+      {
+        assertion = !config.boot.initrd.systemd.enable;
+        message = "systemd stage 1 does not support iscsi yet.";
+      }
     ];
   };
 }
diff --git a/nixos/modules/system/boot/grow-partition.nix b/nixos/modules/system/boot/grow-partition.nix
index 034b2b9906f..a2764187a53 100644
--- a/nixos/modules/system/boot/grow-partition.nix
+++ b/nixos/modules/system/boot/grow-partition.nix
@@ -17,6 +17,11 @@ with lib;
 
   config = mkIf config.boot.growPartition {
 
+    assertions = [{
+      assertion = !config.boot.initrd.systemd.enable;
+      message = "systemd stage 1 does not support 'boot.growPartition' yet.";
+    }];
+
     boot.initrd.extraUtilsCommands = ''
       copy_bin_and_libs ${pkgs.gawk}/bin/gawk
       copy_bin_and_libs ${pkgs.gnused}/bin/sed
diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix
index f987aca34f1..6f991b84bbd 100644
--- a/nixos/modules/system/boot/systemd/initrd.nix
+++ b/nixos/modules/system/boot/systemd/initrd.nix
@@ -1,4 +1,4 @@
-{ lib, config, utils, pkgs, ... }:
+{ lib, options, config, utils, pkgs, ... }:
 
 with lib;
 
@@ -338,6 +338,25 @@ in {
   };
 
   config = mkIf (config.boot.initrd.enable && cfg.enable) {
+    assertions = map (name: {
+      assertion = config.boot.initrd.${name} == "";
+      message = ''
+        systemd stage 1 does not support 'boot.initrd.${name}'. Please
+        convert it to analogous systemd units in 'boot.initrd.systemd'.
+
+          Definitions:
+          ${lib.concatMapStringsSep "\n" ({ file, ... }: "- ${file}") options.boot.initrd.${name}.definitionsWithLocations}
+      '';
+    }) [
+      "preFailCommands"
+      "preDeviceCommands"
+      "preLVMCommands"
+      "postDeviceCommands"
+      "postMountCommands"
+      "extraUtilsCommands"
+      "extraUtilsCommandsTest"
+    ];
+
     system.build = { inherit initialRamdisk; };
 
     boot.initrd.availableKernelModules = [