~ruther/guix-config

ref: 31ca5064cb31cda239344c06cd609026f38cf74b guix-config/modules/ruther/services/system.scm -rw-r--r-- 1.3 KiB
31ca5064 — Rutherther feat: core dumps service for putting core dumps to system folder 6 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(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)))))
Do not follow this link