nixos: systemd: split off coredump into separate module
This commit is contained in:
parent
7adc8ecac3
commit
ccfcb78a50
|
@ -1166,6 +1166,7 @@
|
||||||
./system/boot/stage-1.nix
|
./system/boot/stage-1.nix
|
||||||
./system/boot/stage-2.nix
|
./system/boot/stage-2.nix
|
||||||
./system/boot/systemd.nix
|
./system/boot/systemd.nix
|
||||||
|
./system/boot/systemd/coredump.nix
|
||||||
./system/boot/systemd/journald.nix
|
./system/boot/systemd/journald.nix
|
||||||
./system/boot/systemd/logind.nix
|
./system/boot/systemd/logind.nix
|
||||||
./system/boot/systemd/nspawn.nix
|
./system/boot/systemd/nspawn.nix
|
||||||
|
|
|
@ -80,10 +80,6 @@ let
|
||||||
"printer.target"
|
"printer.target"
|
||||||
"smartcard.target"
|
"smartcard.target"
|
||||||
|
|
||||||
# Coredumps.
|
|
||||||
"systemd-coredump.socket"
|
|
||||||
"systemd-coredump@.service"
|
|
||||||
|
|
||||||
# Kernel module loading.
|
# Kernel module loading.
|
||||||
"systemd-modules-load.service"
|
"systemd-modules-load.service"
|
||||||
"kmod-static-nodes.service"
|
"kmod-static-nodes.service"
|
||||||
|
@ -354,26 +350,6 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.coredump.enable = mkOption {
|
|
||||||
default = true;
|
|
||||||
type = types.bool;
|
|
||||||
description = ''
|
|
||||||
Whether core dumps should be processed by
|
|
||||||
<command>systemd-coredump</command>. If disabled, core dumps
|
|
||||||
appear in the current directory of the crashing process.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.coredump.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.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.extraConfig = mkOption {
|
systemd.extraConfig = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
|
@ -650,21 +626,11 @@ in
|
||||||
${config.systemd.user.extraConfig}
|
${config.systemd.user.extraConfig}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
"systemd/coredump.conf".text =
|
|
||||||
''
|
|
||||||
[Coredump]
|
|
||||||
${config.systemd.coredump.extraConfig}
|
|
||||||
'';
|
|
||||||
|
|
||||||
"systemd/sleep.conf".text = ''
|
"systemd/sleep.conf".text = ''
|
||||||
[Sleep]
|
[Sleep]
|
||||||
${config.systemd.sleep.extraConfig}
|
${config.systemd.sleep.extraConfig}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# install provided sysctl snippets
|
|
||||||
"sysctl.d/50-coredump.conf".source = "${systemd}/example/sysctl.d/50-coredump.conf";
|
|
||||||
"sysctl.d/50-default.conf".source = "${systemd}/example/sysctl.d/50-default.conf";
|
|
||||||
|
|
||||||
"tmpfiles.d".source = (pkgs.symlinkJoin {
|
"tmpfiles.d".source = (pkgs.symlinkJoin {
|
||||||
name = "tmpfiles.d";
|
name = "tmpfiles.d";
|
||||||
paths = map (p: p + "/lib/tmpfiles.d") cfg.tmpfiles.packages;
|
paths = map (p: p + "/lib/tmpfiles.d") cfg.tmpfiles.packages;
|
||||||
|
@ -686,11 +652,6 @@ in
|
||||||
|
|
||||||
services.dbus.enable = true;
|
services.dbus.enable = true;
|
||||||
|
|
||||||
users.users.systemd-coredump = {
|
|
||||||
uid = config.ids.uids.systemd-coredump;
|
|
||||||
group = "systemd-coredump";
|
|
||||||
};
|
|
||||||
users.groups.systemd-coredump = {};
|
|
||||||
users.users.systemd-network = {
|
users.users.systemd-network = {
|
||||||
uid = config.ids.uids.systemd-network;
|
uid = config.ids.uids.systemd-network;
|
||||||
group = "systemd-network";
|
group = "systemd-network";
|
||||||
|
@ -813,8 +774,6 @@ in
|
||||||
systemd.services.systemd-remount-fs.unitConfig.ConditionVirtualization = "!container";
|
systemd.services.systemd-remount-fs.unitConfig.ConditionVirtualization = "!container";
|
||||||
systemd.services.systemd-random-seed.unitConfig.ConditionVirtualization = "!container";
|
systemd.services.systemd-random-seed.unitConfig.ConditionVirtualization = "!container";
|
||||||
|
|
||||||
boot.kernel.sysctl."kernel.core_pattern" = mkIf (!cfg.coredump.enable) "core";
|
|
||||||
|
|
||||||
# Increase numeric PID range (set directly instead of copying a one-line file from systemd)
|
# Increase numeric PID range (set directly instead of copying a one-line file from systemd)
|
||||||
# https://github.com/systemd/systemd/pull/12226
|
# https://github.com/systemd/systemd/pull/12226
|
||||||
boot.kernel.sysctl."kernel.pid_max" = mkIf pkgs.stdenv.is64bit (lib.mkDefault 4194304);
|
boot.kernel.sysctl."kernel.pid_max" = mkIf pkgs.stdenv.is64bit (lib.mkDefault 4194304);
|
||||||
|
|
57
nixos/modules/system/boot/systemd/coredump.nix
Normal file
57
nixos/modules/system/boot/systemd/coredump.nix
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
{ config, lib, pkgs, utils, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
systemd = config.systemd.package;
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
systemd.coredump.enable = mkOption {
|
||||||
|
default = true;
|
||||||
|
type = types.bool;
|
||||||
|
description = ''
|
||||||
|
Whether core dumps should be processed by
|
||||||
|
<command>systemd-coredump</command>. If disabled, core dumps
|
||||||
|
appear in the current directory of the crashing process.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.coredump.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.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
systemd.additionalUpstreamSystemUnits = [
|
||||||
|
# Coredumps.
|
||||||
|
"systemd-coredump.socket"
|
||||||
|
"systemd-coredump@.service"
|
||||||
|
];
|
||||||
|
|
||||||
|
environment.etc = {
|
||||||
|
"systemd/coredump.conf".text =
|
||||||
|
''
|
||||||
|
[Coredump]
|
||||||
|
${config.systemd.coredump.extraConfig}
|
||||||
|
'';
|
||||||
|
|
||||||
|
# install provided sysctl snippets
|
||||||
|
"sysctl.d/50-coredump.conf".source = "${systemd}/example/sysctl.d/50-coredump.conf";
|
||||||
|
"sysctl.d/50-default.conf".source = "${systemd}/example/sysctl.d/50-default.conf";
|
||||||
|
};
|
||||||
|
|
||||||
|
users.users.systemd-coredump = {
|
||||||
|
uid = config.ids.uids.systemd-coredump;
|
||||||
|
group = "systemd-coredump";
|
||||||
|
};
|
||||||
|
users.groups.systemd-coredump = {};
|
||||||
|
|
||||||
|
boot.kernel.sysctl."kernel.core_pattern" = mkIf (!config.systemd.coredump.enable) "core";
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue