summaryrefslogtreecommitdiffstats
path: root/nixos/modules/installer/netboot/netboot.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/installer/netboot/netboot.nix')
-rw-r--r--nixos/modules/installer/netboot/netboot.nix31
1 files changed, 31 insertions, 0 deletions
diff --git a/nixos/modules/installer/netboot/netboot.nix b/nixos/modules/installer/netboot/netboot.nix
index a459e7304cd4..3127bdc436f9 100644
--- a/nixos/modules/installer/netboot/netboot.nix
+++ b/nixos/modules/installer/netboot/netboot.nix
@@ -101,6 +101,37 @@ with lib;
boot
'';
+ # A script invoking kexec on ./bzImage and ./initrd.gz.
+ # Usually used through system.build.kexecTree, but exposed here for composability.
+ system.build.kexecScript = pkgs.writeScript "kexec-boot" ''
+ #!/usr/bin/env bash
+ if ! kexec -v >/dev/null 2>&1; then
+ echo "kexec not found: please install kexec-tools" 2>&1
+ exit 1
+ fi
+ SCRIPT_DIR=$( cd -- "$( dirname -- "''${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
+ kexec --load ''${SCRIPT_DIR}/bzImage \
+ --initrd=''${SCRIPT_DIR}/initrd.gz \
+ --command-line "init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}"
+ kexec -e
+ '';
+
+ # A tree containing initrd.gz, bzImage and a kexec-boot script.
+ system.build.kexecTree = pkgs.linkFarm "kexec-tree" [
+ {
+ name = "initrd.gz";
+ path = "${config.system.build.netbootRamdisk}/initrd";
+ }
+ {
+ name = "bzImage";
+ path = "${config.system.build.kernel}/${config.system.boot.loader.kernelFile}";
+ }
+ {
+ name = "kexec-boot";
+ path = config.system.build.kexecScript;
+ }
+ ];
+
boot.loader.timeout = 10;
boot.postBootCommands =