(define-module (ruther services system) #:use-module (guix gexp) #:use-module (gnu services) #:use-module (gnu services sysctl) #:use-module (gnu services configuration)) (define-configuration core-dumps-configuration (folder (string "/var/lib/dumps") "The folder to put the core dumps to. It will be automatically created.") (format (string "%t-core.%p.%e") "The format of the file name, see kernel manual (man 5 core) for details") (no-serialization)) (define (core-dumps-sysctl config) (let* ((state-dir (core-dumps-configuration-folder config)) (format (core-dumps-configuration-format config)) (full (string-append state-dir "/" format))) `(("kernel.core_pattern" . ,full)))) (define (%core-dumps-activation config) (let ((state-dir (core-dumps-configuration-folder config))) #~(begin (use-modules (guix build utils)) (mkdir-p #$state-dir) (chmod #$state-dir #o777)))) (define-public core-dumps-service-type (service-type (name 'core-dumps) (description "A service to dump core dumps into a global folder.") (default-value (core-dumps-configuration)) (extensions (list (service-extension activation-service-type %core-dumps-activation) (service-extension sysctl-service-type core-dumps-sysctl)))))