blob: 4b0b646fc01310285cf6f0136871cb15e742b40a (
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
61
62
63
64
65
|
(define-module (upstream services nbfc)
;; #:use-module (gnu packages linux)
#:use-module (gnu services)
#:use-module (gnu services shepherd)
#:use-module (guix build utils)
#:use-module (guix gexp)
#:use-module (guix records)
#:use-module (upstream packages nbfc)
#:export (nbfc-configuration))
(define-record-type* <nbfc-configuration>
nbfc-configuration
make-nbfc-configuration
nbfc-configuration?
(package get-nbfc-configuration-package
(default nbfc-linux))
(model get-nbfc-configuration-model
(default "undefined")))
(define (nbfc-etc-extension configuration-record)
(let* ((model (get-nbfc-configuration-model configuration-record))
(nbfc-configuration-file (mixed-text-file "nbfc.json-stored"
"{\"SelectedConfigId\": \""
model
"\"}\n")))
(list `("nbfc.json" ,nbfc-configuration-file))))
(define nbfc-profile-extension
(lambda (configuration-record)
(list (get-nbfc-configuration-package configuration-record))))
(define (nbfc-shepherd-extension configuration-record)
(let* ((profile (get-nbfc-configuration-package configuration-record))
(service-executable (file-append profile
"/bin/nbfc_service"))
(start-command #~ (list #$ service-executable
"--config-file"
"/etc/nbfc.json"))
(start-process #~ (make-forkexec-constructor #$ start-command))
(symbols (list 'nbfc))
(default-service (shepherd-service (provision symbols)
(start start-process))))
(list default-service)))
(define-public nbfc-service-type
(let* ((nbfc-etc-extension* (service-extension etc-service-type
nbfc-etc-extension))
(nbfc-profile-extension* (service-extension profile-service-type
nbfc-profile-extension))
(nbfc-shepherd-extension* (service-extension shepherd-root-service-type
nbfc-shepherd-extension))
(description "C port of Stefan Hirschmann's NoteBook FanControl")
(extensions (list nbfc-etc-extension*
nbfc-profile-extension*
nbfc-shepherd-extension*)))
(service-type (name 'nbfc)
(extensions extensions)
(description description)
(default-value (nbfc-configuration)))))
|