diff options
author | Ian Eure <ian@retrospec.tv> | 2024-06-01 11:15:49 -0700 |
---|---|---|
committer | Guix Patches Tester <> | 2024-06-01 20:41:25 +0200 |
commit | 32e08b3a134c4463a37d74d45dcd270416c97162 (patch) | |
tree | 9060ed6e136bf71457889c3a9ca29279b148a788 | |
parent | fba6896f625dcbeef112387fc90abe83acae1720 (diff) | |
download | guix-patches-issue-68309.tar guix-patches-issue-68309.tar.gz |
gnu: Add powertop-service-type.issue-68309
* 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
-rw-r--r-- | doc/guix.texi | 25 | ||||
-rw-r--r-- | gnu/services/pm.scm | 42 |
2 files changed, 66 insertions, 1 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index 1224104038..031a4e61c2 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35375,6 +35375,31 @@ 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 lisp +@end defvar + +Available @code{powertop-configuration} fields are: + +@deftypevr {@code{powertop-configuration} parameter} package powertop +The PowerTOP package. Defaults to @code{powertop} in the @code{(gnu +packages linux)} module + +@end deftypevr + @end table @end deftp diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm index 47f0bf7812..1793bc873d 100644 --- a/gnu/services/pm.scm +++ b/gnu/services/pm.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2024 Dariqq <dariqq@posteo.net> +;;; Copyright © 2024 Ian Eure <ian@retrospec.tv> ;;; ;;; This file is part of GNU Guix. ;;; @@ -18,6 +19,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) @@ -37,7 +40,10 @@ tlp-configuration thermald-configuration - thermald-service-type)) + thermald-service-type + + powertop-configuration + powertop-service-type)) ;;; ;;; power-profiles-daemon @@ -524,3 +530,37 @@ shutdown on system startup.")) (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."))) |