at 15.09-beta 2.4 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 crashdump = config.boot.crashDump; 7 8 kernelParams = concatStringsSep " " crashdump.kernelParams; 9 10in 11###### interface 12{ 13 options = { 14 boot = { 15 crashDump = { 16 enable = mkOption { 17 type = types.bool; 18 default = false; 19 description = '' 20 If enabled, NixOS will set up a kernel that will 21 boot on crash, and leave the user to a stage1 debug1devices 22 interactive shell to be able to save the crashed kernel dump. 23 It also activates the NMI watchdog. 24 ''; 25 }; 26 kernelPackages = mkOption { 27 default = pkgs.linuxPackages; 28 # We don't want to evaluate all of linuxPackages for the manual 29 # - some of it might not even evaluate correctly. 30 defaultText = "pkgs.linuxPackages"; 31 example = literalExample "pkgs.linuxPackages_2_6_25"; 32 description = '' 33 This will override the boot.kernelPackages, and will add some 34 kernel configuration parameters for the crash dump to work. 35 ''; 36 }; 37 kernelParams = mkOption { 38 type = types.listOf types.str; 39 default = [ "debug1devices" ]; 40 description = '' 41 Parameters that will be passed to the kernel kexec-ed on crash. 42 ''; 43 }; 44 }; 45 }; 46 }; 47 48###### implementation 49 50 config = mkIf crashdump.enable { 51 boot = { 52 postBootCommands = '' 53 ${pkgs.kexectools}/sbin/kexec -p /run/current-system/kernel \ 54 --initrd=/run/current-system/initrd \ 55 --append="init=$(readlink -f /run/current-system/init) system=$(readlink -f /run/current-system) irqpoll maxcpus=1 reset_devices ${kernelParams}" --reset-vga --console-vga 56 ''; 57 kernelParams = [ 58 "crashkernel=64M" 59 "nmi_watchdog=panic" 60 "softlockup_panic=1" 61 "idle=poll" 62 ]; 63 kernelPackages = mkOverride 50 (crashdump.kernelPackages // { 64 kernel = crashdump.kernelPackages.kernel.override 65 (attrs: { 66 extraConfig = (optionalString (attrs ? extraConfig) attrs.extraConfig) + 67 '' 68 CRASH_DUMP y 69 DEBUG_INFO y 70 PROC_VMCORE y 71 LOCKUP_DETECTOR y 72 HARDLOCKUP_DETECTOR y 73 ''; 74 }); 75 }); 76 }; 77 }; 78}