2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2012-03-17 22:21:37 +00:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2012-03-17 22:21:37 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
crashdump = config.boot.crashDump;
|
2012-03-18 10:02:58 +00:00
|
|
|
|
|
|
|
kernelParams = concatStringsSep " " crashdump.kernelParams;
|
2012-09-05 08:55:02 +01:00
|
|
|
|
2012-03-17 22:21:37 +00:00
|
|
|
in
|
|
|
|
###### interface
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
boot = {
|
|
|
|
crashDump = {
|
|
|
|
enable = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.bool;
|
2012-03-17 22:21:37 +00:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
If enabled, NixOS will set up a kernel that will
|
|
|
|
boot on crash, and leave the user to a stage1 debug1devices
|
|
|
|
interactive shell to be able to save the crashed kernel dump.
|
|
|
|
It also activates the NMI watchdog.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
kernelPackages = mkOption {
|
|
|
|
default = pkgs.linuxPackages;
|
|
|
|
# We don't want to evaluate all of linuxPackages for the manual
|
|
|
|
# - some of it might not even evaluate correctly.
|
|
|
|
defaultText = "pkgs.linuxPackages";
|
|
|
|
example = "pkgs.linuxPackages_2_6_25";
|
|
|
|
description = ''
|
|
|
|
This will override the boot.kernelPackages, and will add some
|
|
|
|
kernel configuration parameters for the crash dump to work.
|
|
|
|
'';
|
|
|
|
};
|
2012-03-18 10:02:58 +00:00
|
|
|
kernelParams = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.listOf types.str;
|
2012-03-18 10:02:58 +00:00
|
|
|
default = [ "debug1devices" ];
|
|
|
|
description = ''
|
|
|
|
Parameters that will be passed to the kernel kexec-ed on crash.
|
|
|
|
'';
|
|
|
|
};
|
2012-03-17 22:21:37 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf crashdump.enable {
|
|
|
|
boot = {
|
|
|
|
postBootCommands = ''
|
2012-07-16 16:27:59 +01:00
|
|
|
${pkgs.kexectools}/sbin/kexec -p /run/current-system/kernel \
|
|
|
|
--initrd=/run/current-system/initrd \
|
|
|
|
--append="init=$(readlink -f /run/current-system/init) system=$(readlink -f /run/current-system) irqpoll maxcpus=1 reset_devices ${kernelParams}" --reset-vga --console-vga
|
2012-03-17 22:21:37 +00:00
|
|
|
'';
|
|
|
|
kernelParams = [
|
|
|
|
"crashkernel=64M"
|
2012-07-18 20:50:18 +01:00
|
|
|
"nmi_watchdog=panic"
|
2012-09-05 08:55:02 +01:00
|
|
|
"softlockup_panic=1"
|
|
|
|
"idle=poll"
|
2012-03-17 22:21:37 +00:00
|
|
|
];
|
2012-03-18 10:02:58 +00:00
|
|
|
kernelPackages = mkOverride 50 (crashdump.kernelPackages // {
|
2012-03-17 22:21:37 +00:00
|
|
|
kernel = crashdump.kernelPackages.kernel.override
|
|
|
|
(attrs: {
|
|
|
|
extraConfig = (optionalString (attrs ? extraConfig) attrs.extraConfig) +
|
|
|
|
''
|
|
|
|
CRASH_DUMP y
|
|
|
|
DEBUG_INFO y
|
|
|
|
PROC_VMCORE y
|
2012-07-18 20:50:18 +01:00
|
|
|
LOCKUP_DETECTOR y
|
|
|
|
HARDLOCKUP_DETECTOR y
|
2012-03-17 22:21:37 +00:00
|
|
|
'';
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|