aboutsummaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorIan Eure <ian@retrospec.tv>2024-06-01 11:15:49 -0700
committerLudovic Courtès <ludo@gnu.org>2024-11-23 16:09:25 +0100
commitea5ee89274d47d06d05feed927c0eb50ae316db3 (patch)
treee648bab20d0c1ccc6f40a5a6d446aa3ac9a16d9b /gnu/services
parent2b8d612f4ea8d0a681c7865a84c190533de3d2f3 (diff)
downloadguix-ea5ee89274d47d06d05feed927c0eb50ae316db3.tar
guix-ea5ee89274d47d06d05feed927c0eb50ae316db3.tar.gz
gnu: Add powertop-service-type.
* gnu/services/pm.scm (powertop-shepherd-service) (powertop-service-type, powertop-configuration): New variables. * doc/guix.texi (Power Management Services): Document powertop-service-type. Change-Id: I1c5ef855526458ad54f62ca6e755da82acce1c4a Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/pm.scm42
1 files changed, 41 insertions, 1 deletions
diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm
index 5e8e7efda2..1978de55d4 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
@@ -525,3 +531,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.")))