[bug#68309,1/2] gnu: Add powertop-service-type.
Commit Message
* gnu/services/pm.scm (powertop-shepherd-service): New variable.
* gnu/services/pm.scm (powertop-service-type): New variable.
* gnu/services/pm.scm (powertop-configuration): New variable.
* doc/guix.texi (Power Management Services): Document powertop-service-type.
Change-Id: I1c5ef855526458ad54f62ca6e755da82acce1c4a
---
doc/guix.texi | 24 ++++++++++++++++++++++++
gnu/services/pm.scm | 43 ++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 66 insertions(+), 1 deletion(-)
Comments
Hey,
Thanks for the v2!
> +The @code{(gnu services pm)} module provides a Guix service definition
> +for PowerTOP. When started, it tunes kernel settings to reduce power
> +consumption.
I have this error when building the documentation:
--8<---------------cut here---------------start------------->8---
guix.texi:34841: `@end' expected `lisp', but saw `defvar'
--8<---------------cut here---------------end--------------->8---
> +
> +
> +
Kill that extra line
> +;;;
> +;;; powertop
> +;;;
> +;;; Calls `powertop --auto-tune' to reduce energy consumption.
> +
> +
That one too.
> + (description "Tune power-related kernel parameters to reduce energy consumption.")))
Wrap it to be under 78 characters.
Thanks,
Mathieu
Hi Mathieu,
Sorry for the extremely late response on this.
Mathieu Othacehe <othacehe@gnu.org> writes:
> Hey,
>
> Thanks for the v2!
>
>> +The @code{(gnu services pm)} module provides a Guix service
>> definition
>> +for PowerTOP. When started, it tunes kernel settings to
>> reduce power
>> +consumption.
>
> I have this error when building the documentation:
>
> guix.texi:34841: `@end' expected `lisp', but saw `defvar'
>
Fixed in v3, which I just sent.
>> +
>> +
>> +
>
> Kill that extra line
>
This matches the style used by every other package in the module,
so I believe it should stay how it is.
>> +;;;
>> +;;; powertop
>> +;;;
>> +;;; Calls `powertop --auto-tune' to reduce energy consumption.
>> +
>> +
>
> That one too.
>
Done.
>> + (description "Tune power-related kernel parameters to
>> reduce energy consumption.")))
>
> Wrap it to be under 78 characters.
>
Done.
— Ian
@@ -34798,6 +34798,30 @@ Ignore cpuid check for supported CPU models.
@item @code{thermald} (default: @var{thermald})
Package object of thermald.
+@cindex powertop
+@cindex Power tuning with PowerTOP
+@subsubheading PowerTOP
+
+The @code{(gnu services pm)} module provides a Guix service definition
+for PowerTOP. When started, it tunes kernel settings to reduce power
+consumption.
+
+@defvar powertop-service-type
+The service type for PowerTOP. No configuration is necessary. When the
+service starts, it executes @code{powertop --auto-tune}.
+
+@lisp
+(service powertop-service-type)
+
+@end defvar
+
+Available @code{powertop-configuration} fields are:
+
+@deftypevr {@code{powertop-configuration} parameter} package powertop
+The PowerTOP package. Defaults to @code{powertop}.
+
+@end deftypevr
+
@end table
@end deftp
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2024 Ian Eure <ian@retrospec.tv>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -17,6 +18,8 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu services pm)
+ #:use-module (srfi srfi-1)
+ #:use-module (ice-9 match)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix records)
@@ -31,7 +34,10 @@ (define-module (gnu services pm)
tlp-configuration
thermald-configuration
- thermald-service-type))
+ thermald-service-type
+
+ powertop-configuration
+ powertop-service-type))
(define (uglify-field-name field-name)
(let ((str (symbol->string field-name)))
@@ -466,3 +472,38 @@ (define thermald-service-type
(default-value (thermald-configuration))
(description "Run thermald, a CPU frequency scaling service that helps
prevent overheating.")))
+
+
+
+;;;
+;;; powertop
+;;;
+;;; Calls `powertop --auto-tune' to reduce energy consumption.
+
+
+
+(define-configuration powertop-configuration
+ (powertop (package powertop) "PowerTOP package to use."))
+
+(define powertop-shepherd-service
+ (match-lambda
+ (($ <powertop-configuration> powertop)
+ (shepherd-service
+ (documentation "Tune kernel power settings at boot.")
+ (provision '(powertop powertop-auto-tune))
+ (requirement '(user-processes))
+ (one-shot? #t)
+ (start #~(lambda _
+ (zero? (system* #$(file-append powertop "/sbin/powertop")
+ "--auto-tune"))))))))
+
+(define powertop-service-type
+ (service-type
+ (name 'powertop)
+ (extensions
+ (list
+ (service-extension shepherd-root-service-type
+ (compose list powertop-shepherd-service))))
+ (compose concatenate)
+ (default-value (powertop-configuration))
+ (description "Tune power-related kernel parameters to reduce energy consumption.")))