blob: b2bd04e70eeb01200eb32f09b1c2629cc6b1d6ed (
plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
(define-module (kbg services boltd)
#:use-module (ice-9 match)
#:use-module (gnu)
#:use-module (guix)
#:use-module (guix records)
#:use-module (guix modules)
#:use-module (gnu system shadow)
#:use-module (gnu services)
#:use-module (gnu services shepherd)
#:use-module (gnu services dbus)
#:use-module (gnu packages linux)
#:export (boltd-configuration
boltd-configuration?
boltd-service-type))
(define-record-type* <boltd-configuration>
boltd-configuration make-boltd-configuration boltd-configuration?
(package boltd-configuration-package ; package
(default bolt)))
(define (boltd-shepherd-service config)
(shepherd-service
(documentation "Thunderbolt daemon")
(provision '(boltd))
(requirement '(dbus-system udev))
(respawn? #f)
(start #~(make-forkexec-constructor
(list #$(file-append (boltd-configuration-package config)
"/libexec/boltd")
"--verbose")
#:log-file "/var/log/boltd"))
(stop #~(make-kill-destructor))))
(define boltd-activation-service
#~(begin
(use-modules (guix build utils))
(mkdir-p "/var/lib/boltd")))
(define (boltd-udev-rule config)
(let ((package (boltd-configuration-package config)))
(file->udev-rule "90-bolt.rules"
(file-append package
"/lib/udev/rules.d/90-bolt.rules"))))
(define boltd-service-type
(service-type
(name 'boltd)
(description
"Run @command{boltd}, the Thunderbolt daemon.")
(extensions
(list (service-extension udev-service-type
(compose list boltd-udev-rule))
(service-extension activation-service-type
(const boltd-activation-service))
(service-extension dbus-root-service-type
(compose list boltd-configuration-package))
(service-extension shepherd-root-service-type
(compose list boltd-shepherd-service))))
(default-value (boltd-configuration))))
|