summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2017-05-13 19:37:02 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2017-05-14 18:56:32 -0500
commitd7fa39ccec34bc223d52a04dfc3e1f756e2dfa24 (patch)
treec103ddbca934dd4e9098e3786c6eee7e39c2d8b6
parent589896843854cbdb24f627a53e5a9af628c6e7fb (diff)
services: Add 'thermald-service-type'.
* gnu/services/pm.scm (<thermald-configuration>): New record type. (thermald-shepherd-service, thermald-service-type): New variables. * doc/guix.texi (Thermal Management): New section documenting thermald.
-rw-r--r--doc/guix.texi28
-rw-r--r--gnu/services/pm.scm41
2 files changed, 67 insertions, 2 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 844f0d74fb4..43ed051493a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -35,7 +35,8 @@ Copyright @copyright{} 2017 Mathieu Othacehe@*
35Copyright @copyright{} 2017 Federico Beffa@* 35Copyright @copyright{} 2017 Federico Beffa@*
36Copyright @copyright{} 2017 Carlo Zancanaro@* 36Copyright @copyright{} 2017 Carlo Zancanaro@*
37Copyright @copyright{} 2017 Thomas Danckaert@* 37Copyright @copyright{} 2017 Thomas Danckaert@*
38Copyright @copyright{} 2017 humanitiesNerd 38Copyright @copyright{} 2017 humanitiesNerd@*
39Copyright @copyright{} 2017 Christopher Allan Webber
39 40
40Permission is granted to copy, distribute and/or modify this document 41Permission is granted to copy, distribute and/or modify this document
41under the terms of the GNU Free Documentation License, Version 1.3 or 42under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -14617,6 +14618,31 @@ Defaults to @samp{#f}.
14617 14618
14618@end deftypevr 14619@end deftypevr
14619 14620
14621
14622The @code{(gnu services pm)} module provides an interface to
14623thermald, a CPU frequency scaling service which helps prevent overheating.
14624
14625@defvr {Scheme Variable} thermald-service-type
14626This is the service type for
14627@uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
14628Thermal Daemon, which is responsible for controlling the thermal state
14629of processors and preventing overheating.
14630@end defvr
14631
14632@deftp {Data Type} thermald-configuration
14633Data type representing the configuration of @code{thermald-service-type}.
14634
14635@table @asis
14636@item @code{ignore-cpuid-check?} (default: @code{#f})
14637Ignore cpuid check for supported CPU models.
14638
14639@item @code{thermald} (default: @var{thermald})
14640Package object of thermald.
14641
14642@end table
14643@end deftp
14644
14645
14620@node Miscellaneous Services 14646@node Miscellaneous Services
14621@subsubsection Miscellaneous Services 14647@subsubsection Miscellaneous Services
14622 14648
diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm
index 3cefe1874a6..d40cb993e2b 100644
--- a/gnu/services/pm.scm
+++ b/gnu/services/pm.scm
@@ -20,6 +20,7 @@
20 #:use-module (guix gexp) 20 #:use-module (guix gexp)
21 #:use-module (guix packages) 21 #:use-module (guix packages)
22 #:use-module (guix records) 22 #:use-module (guix records)
23 #:use-module (gnu packages admin)
23 #:use-module (gnu packages linux) 24 #:use-module (gnu packages linux)
24 #:use-module (gnu services) 25 #:use-module (gnu services)
25 #:use-module (gnu services base) 26 #:use-module (gnu services base)
@@ -27,7 +28,10 @@
27 #:use-module (gnu services shepherd) 28 #:use-module (gnu services shepherd)
28 #:use-module (gnu system shadow) 29 #:use-module (gnu system shadow)
29 #:export (tlp-service-type 30 #:export (tlp-service-type
30 tlp-configuration)) 31 tlp-configuration
32
33 thermald-configuration
34 thermald-service-type))
31 35
32(define (uglify-field-name field-name) 36(define (uglify-field-name field-name)
33 (let ((str (symbol->string field-name))) 37 (let ((str (symbol->string field-name)))
@@ -403,3 +407,38 @@ shutdown on system startup."))
403 (generate-documentation 407 (generate-documentation
404 `((tlp-configuration ,tlp-configuration-fields)) 408 `((tlp-configuration ,tlp-configuration-fields))
405 'tlp-configuration)) 409 'tlp-configuration))
410
411
412
413;;;
414;;; thermald
415;;;
416;;; This service implements cpu scaling. Helps prevent overheating!
417
418(define-record-type* <thermald-configuration>
419 thermald-configuration make-thermald-configuration
420 thermald-configuration?
421 (ignore-cpuid-check? thermald-ignore-cpuid-check? ;boolean
422 (default #f))
423 (thermald thermald-thermald ;package
424 (default thermald)))
425
426(define (thermald-shepherd-service config)
427 (list
428 (shepherd-service
429 (provision '(thermald))
430 (documentation "Run thermald cpu frequency scaling.")
431 (start #~(make-forkexec-constructor
432 '(#$(file-append (thermald-thermald config) "/sbin/thermald")
433 "--no-daemon"
434 #$@(if (thermald-ignore-cpuid-check? config)
435 '("--ignore-cpuid-check")
436 '()))))
437 (stop #~(make-kill-destructor)))))
438
439(define thermald-service-type
440 (service-type
441 (name 'thermald)
442 (extensions (list (service-extension shepherd-root-service-type
443 thermald-shepherd-service)))
444 (default-value (thermald-configuration))))