2015-02-05 09:42:00 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
systemd.coredump = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Enables storing core dumps in systemd.
|
|
|
|
Note that this alone is not enough to enable core dumps. The maximum
|
|
|
|
file size for core dumps must be specified in limits.conf as well. See
|
|
|
|
<option>security.pam.loginLimits</option> as well as the limits.conf(5)
|
|
|
|
man page.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
|
|
|
example = "Storage=journal";
|
|
|
|
description = ''
|
|
|
|
Extra config options for systemd-coredump. See coredump.conf(5) man page
|
|
|
|
for available options.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-03-25 17:29:02 +01:00
|
|
|
config = mkMerge [
|
|
|
|
(mkIf config.systemd.coredump.enable {
|
2015-02-05 09:42:00 +01:00
|
|
|
|
2016-03-25 17:29:02 +01:00
|
|
|
environment.etc."systemd/coredump.conf".text =
|
|
|
|
''
|
|
|
|
[Coredump]
|
|
|
|
${config.systemd.coredump.extraConfig}
|
|
|
|
'';
|
2015-02-05 09:42:00 +01:00
|
|
|
|
2016-03-25 17:29:02 +01:00
|
|
|
# Have the kernel pass core dumps to systemd's coredump helper binary.
|
|
|
|
# From systemd's 50-coredump.conf file. See:
|
|
|
|
# <https://github.com/systemd/systemd/blob/v218/sysctl.d/50-coredump.conf.in>
|
|
|
|
boot.kernel.sysctl."kernel.core_pattern" = "|${pkgs.systemd}/lib/systemd/systemd-coredump %p %u %g %s %t %e";
|
|
|
|
})
|
2015-02-05 09:42:00 +01:00
|
|
|
|
2016-03-25 17:29:02 +01:00
|
|
|
(mkIf (!config.systemd.coredump.enable) {
|
|
|
|
boot.kernel.sysctl."kernel.core_pattern" = mkDefault "core";
|
2016-04-14 13:15:20 +02:00
|
|
|
|
|
|
|
systemd.extraConfig =
|
|
|
|
''
|
|
|
|
DefaultLimitCORE=0:infinity
|
|
|
|
'';
|
2016-03-25 17:29:02 +01:00
|
|
|
})
|
|
|
|
];
|
2015-02-05 09:42:00 +01:00
|
|
|
|
|
|
|
}
|