thinkfan-service-type: Add thinkfan entry to thinkfan-configuration.

pull/1/head
Luis Guilherme Coelho 2023-12-27 14:17:49 -03:00
parent fa8a617be6
commit 7e88398dbc
No known key found for this signature in database
GPG Key ID: 1F2E76ACE3F531C8
2 changed files with 11 additions and 17 deletions

View File

@ -107,7 +107,7 @@
#|guile |# guile-3.0-latest guile-colorized guile-readline
#|less |# less
#|linux |# e2fsprogs eudev fuse iproute kbd kmod lm-sensors procps
psmisc thinkfan-next util-linux
psmisc util-linux
#|man |# man-db mandoc man-pages
#|shells |# dash-next
#|texinfo |# info-reader
@ -247,6 +247,7 @@
#|Thinkfan services|#
(service thinkfan-service-type
(thinkfan-configuration
(thinkfan thinkfan-next)
(config-file file:thinkfan-config)))
#|Doas configuration services|#

View File

@ -1,22 +1,13 @@
(define-module (radix services pm)
#:use-module (radix packages linux)
#:use-module (guix packages)
#:use-module (gnu packages linux)
#:use-module (gnu)
#:use-module (gnu services)
#:use-module (gnu services shepherd)
#:use-module (gnu services configuration)
#:use-module (guix gexp)
#:use-module (guix records)
#:use-module (ice-9 curried-definitions)
#:export (thinkfan-configuration
make-thinkfan-configuration
thinkfan-configuration?
thinkfan-configuration-pid-file
thinkfan-configuration-config-file
thinkfan-configuration-log-file
thinkfan-configuration-extra-options
thinkfan-shepherd-service
thinkfan-service-type))
(define (string-or-file-like? x)
@ -24,6 +15,9 @@
(file-like? x)))
(define-configuration/no-serialization thinkfan-configuration
(thinkfan
(package thinkfan)
"Thinkfan package to be used.")
(pid-file
(string "/var/run/thinkfan.pid")
"Where to store the PID file.")
@ -40,17 +34,16 @@ arbitrary command-line arguments to thinkfan as a list of strings."))
(define thinkfan-shepherd-service
(match-record-lambda <thinkfan-configuration>
(pid-file config-file log-file extra-options)
(thinkfan pid-file config-file log-file extra-options)
(list (shepherd-service
(provision '(thinkfan))
(documentation
"Adjust fan level according to configured temperature limits.")
(requirement '(user-processes))
(start #~(make-forkexec-constructor
(list (string-append #$thinkfan-next
"/sbin/thinkfan")
"-n" #$@extra-options
"-c" #$config-file)
(list (string-append #$thinkfan "/sbin/thinkfan")
"-n" #$@extra-options
"-c" #$config-file)
#:log-file #$log-file
#:pid-file #$pid-file))
(stop #~(make-kill-destructor))