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.
This commit is contained in:
Christopher Allan Webber 2017-05-13 19:37:02 -05:00
parent 5898968438
commit d7fa39ccec
No known key found for this signature in database
GPG key ID: 4BC025925FF8F4D3
2 changed files with 67 additions and 2 deletions

View file

@ -35,7 +35,8 @@ Copyright @copyright{} 2017 Mathieu Othacehe@*
Copyright @copyright{} 2017 Federico Beffa@* Copyright @copyright{} 2017 Federico Beffa@*
Copyright @copyright{} 2017 Carlo Zancanaro@* Copyright @copyright{} 2017 Carlo Zancanaro@*
Copyright @copyright{} 2017 Thomas Danckaert@* Copyright @copyright{} 2017 Thomas Danckaert@*
Copyright @copyright{} 2017 humanitiesNerd Copyright @copyright{} 2017 humanitiesNerd@*
Copyright @copyright{} 2017 Christopher Allan Webber
Permission is granted to copy, distribute and/or modify this document Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or under the terms of the GNU Free Documentation License, Version 1.3 or
@ -14617,6 +14618,31 @@ Defaults to @samp{#f}.
@end deftypevr @end deftypevr
The @code{(gnu services pm)} module provides an interface to
thermald, a CPU frequency scaling service which helps prevent overheating.
@defvr {Scheme Variable} thermald-service-type
This is the service type for
@uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
Thermal Daemon, which is responsible for controlling the thermal state
of processors and preventing overheating.
@end defvr
@deftp {Data Type} thermald-configuration
Data type representing the configuration of @code{thermald-service-type}.
@table @asis
@item @code{ignore-cpuid-check?} (default: @code{#f})
Ignore cpuid check for supported CPU models.
@item @code{thermald} (default: @var{thermald})
Package object of thermald.
@end table
@end deftp
@node Miscellaneous Services @node Miscellaneous Services
@subsubsection Miscellaneous Services @subsubsection Miscellaneous Services

View file

@ -20,6 +20,7 @@ (define-module (gnu services pm)
#:use-module (guix gexp) #:use-module (guix gexp)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix records) #:use-module (guix records)
#:use-module (gnu packages admin)
#:use-module (gnu packages linux) #:use-module (gnu packages linux)
#:use-module (gnu services) #:use-module (gnu services)
#:use-module (gnu services base) #:use-module (gnu services base)
@ -27,7 +28,10 @@ (define-module (gnu services pm)
#:use-module (gnu services shepherd) #:use-module (gnu services shepherd)
#:use-module (gnu system shadow) #:use-module (gnu system shadow)
#:export (tlp-service-type #:export (tlp-service-type
tlp-configuration)) tlp-configuration
thermald-configuration
thermald-service-type))
(define (uglify-field-name field-name) (define (uglify-field-name field-name)
(let ((str (symbol->string field-name))) (let ((str (symbol->string field-name)))
@ -403,3 +407,38 @@ (define (generate-tlp-documentation)
(generate-documentation (generate-documentation
`((tlp-configuration ,tlp-configuration-fields)) `((tlp-configuration ,tlp-configuration-fields))
'tlp-configuration)) 'tlp-configuration))
;;;
;;; thermald
;;;
;;; This service implements cpu scaling. Helps prevent overheating!
(define-record-type* <thermald-configuration>
thermald-configuration make-thermald-configuration
thermald-configuration?
(ignore-cpuid-check? thermald-ignore-cpuid-check? ;boolean
(default #f))
(thermald thermald-thermald ;package
(default thermald)))
(define (thermald-shepherd-service config)
(list
(shepherd-service
(provision '(thermald))
(documentation "Run thermald cpu frequency scaling.")
(start #~(make-forkexec-constructor
'(#$(file-append (thermald-thermald config) "/sbin/thermald")
"--no-daemon"
#$@(if (thermald-ignore-cpuid-check? config)
'("--ignore-cpuid-check")
'()))))
(stop #~(make-kill-destructor)))))
(define thermald-service-type
(service-type
(name 'thermald)
(extensions (list (service-extension shepherd-root-service-type
thermald-shepherd-service)))
(default-value (thermald-configuration))))