summary refs log tree commit diff
path: root/nixos/modules/system/boot/coredump.nix
diff options
context:
space:
mode:
authorJonathan Glines <auntieNeo@gmail.com>2015-02-05 01:42:00 -0700
committerJonathan Glines <auntieNeo@gmail.com>2015-05-24 18:22:53 -0600
commit847f8297fc9f2bf692147008b731657182d3a3f2 (patch)
treee8650612007dfc434e14e4d308739334be14b048 /nixos/modules/system/boot/coredump.nix
parentd8dab38fda0e48b31edc6fdd88ebfb1ad08c5105 (diff)
downloadnixlib-847f8297fc9f2bf692147008b731657182d3a3f2.tar
nixlib-847f8297fc9f2bf692147008b731657182d3a3f2.tar.gz
nixlib-847f8297fc9f2bf692147008b731657182d3a3f2.tar.bz2
nixlib-847f8297fc9f2bf692147008b731657182d3a3f2.tar.lz
nixlib-847f8297fc9f2bf692147008b731657182d3a3f2.tar.xz
nixlib-847f8297fc9f2bf692147008b731657182d3a3f2.tar.zst
nixlib-847f8297fc9f2bf692147008b731657182d3a3f2.zip
Added config options for systemd-coredump functionality.
Diffstat (limited to 'nixos/modules/system/boot/coredump.nix')
-rw-r--r--nixos/modules/system/boot/coredump.nix51
1 files changed, 51 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/coredump.nix b/nixos/modules/system/boot/coredump.nix
new file mode 100644
index 000000000000..25b11ed9c8a9
--- /dev/null
+++ b/nixos/modules/system/boot/coredump.nix
@@ -0,0 +1,51 @@
+{ 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.
+        '';
+      };
+    };
+
+  };
+
+  config = mkIf config.systemd.coredump.enable {
+
+    environment.etc."systemd/coredump.conf".text =
+      ''
+        [Coredump]
+        ${config.systemd.coredump.extraConfig}
+      '';
+
+    # 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";
+
+  };
+
+}