about summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2022-11-12 21:12:56 +0100
committerGitHub <noreply@github.com>2022-11-12 21:12:56 +0100
commit9477fa1e44c16804b8c1743d25264f9e3b26c219 (patch)
treeb856b85794f9da36a5d70370c8c879894c583587 /nixos/modules/system
parent192d73761f6739149ce6f9e74a7e78e1e96d2dc5 (diff)
parent182575a60d7e897b62a837fdd8047ae4fe44b4c6 (diff)
Merge pull request #197917 from SuperSandro2000/kernel-enable
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/activation/top-level.nix2
-rw-r--r--nixos/modules/system/boot/kernel.nix5
2 files changed, 5 insertions, 2 deletions
diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix
index 2ff9acd3e2de7..55ff98db53829 100644
--- a/nixos/modules/system/activation/top-level.nix
+++ b/nixos/modules/system/activation/top-level.nix
@@ -14,7 +14,7 @@ let
 
       # Containers don't have their own kernel or initrd.  They boot
       # directly into stage 2.
-      ${optionalString (!config.boot.isContainer) ''
+      ${optionalString config.boot.kernel.enable ''
         if [ ! -f ${kernelPath} ]; then
           echo "The bootloader cannot find the proper kernel image."
           echo "(Expecting ${kernelPath})"
diff --git a/nixos/modules/system/boot/kernel.nix b/nixos/modules/system/boot/kernel.nix
index 8a1630f7e3ebb..6783f8ec62ff9 100644
--- a/nixos/modules/system/boot/kernel.nix
+++ b/nixos/modules/system/boot/kernel.nix
@@ -20,6 +20,9 @@ in
   ###### interface
 
   options = {
+    boot.kernel.enable = mkEnableOption (lib.mdDoc "the Linux kernel. This is useful for systemd-like containers which do not require a kernel.") // {
+      default = true;
+    };
 
     boot.kernel.features = mkOption {
       default = {};
@@ -258,7 +261,7 @@ in
           ];
       })
 
-      (mkIf (!config.boot.isContainer) {
+      (mkIf config.boot.kernel.enable {
         system.build = { inherit kernel; };
 
         system.modulesTree = [ kernel ] ++ config.boot.extraModulePackages;