gnu: services: Add power-profiles-daemon-service-type.
* gnu/services/pm.scm (power-profiles-configuration): New configuration. (power-profiles-daemon-shepherd-service): New procedure. (power-profiles-daemon-activation): New variable. (power-profiles-daemon-service-type): New procedure. * doc/guix.texi (Power Management Services): Document it. Change-Id: Ib035d993ed82eec2a43f3ba2b4c92f77e08a0fd7 Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
		
							parent
							
								
									558e2b07ea
								
							
						
					
					
						commit
						d0ad4f557f
					
				
					 2 changed files with 99 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -127,6 +127,7 @@ Copyright @copyright{} 2023 Tomas Volf@*
 | 
			
		|||
Copyright @copyright{} 2024 Herman Rimm@*
 | 
			
		||||
Copyright @copyright{} 2024 Matthew Trzcinski@*
 | 
			
		||||
Copyright @copyright{} 2024 Richard Sent@*
 | 
			
		||||
Copyright @copyright{} 2024 Dariqq@*
 | 
			
		||||
 | 
			
		||||
Permission is granted to copy, distribute and/or modify this document
 | 
			
		||||
under the terms of the GNU Free Documentation License, Version 1.3 or
 | 
			
		||||
| 
						 | 
				
			
			@ -34711,6 +34712,45 @@ Base URL to use for links to laminar itself.
 | 
			
		|||
@node Power Management Services
 | 
			
		||||
@subsection Power Management Services
 | 
			
		||||
 | 
			
		||||
@cindex power-profiles-daemon
 | 
			
		||||
@subsubheading Power Profiles Daemon
 | 
			
		||||
 | 
			
		||||
The @code{(gnu services pm)} module provides a Guix service definition for
 | 
			
		||||
the Linux Power Profiles Daemon, which makes power profiles handling
 | 
			
		||||
available over D-Bus.
 | 
			
		||||
 | 
			
		||||
The available profiles consist of the default @samp{balanced} mode, a @samp{power-saver} mode
 | 
			
		||||
and on supported systems a @samp{performance} mode.
 | 
			
		||||
 | 
			
		||||
@quotation Important
 | 
			
		||||
The @code{power-profiles-daemon} conflicts with other power management tools
 | 
			
		||||
like @code{tlp}. Using both together is not recommended.
 | 
			
		||||
@end quotation
 | 
			
		||||
 | 
			
		||||
@defvar power-profiles-daemon-service-type
 | 
			
		||||
This is the service type for the
 | 
			
		||||
@uref{https://gitlab.freedesktop.org/upower/power-profiles-daemon/, Power Profiles Daemon}.
 | 
			
		||||
The value for this service is a @code{power-profiles-daemon-configuration}.
 | 
			
		||||
 | 
			
		||||
To enable the Power Profiles Daemon with default configuration
 | 
			
		||||
add this line to your services:
 | 
			
		||||
 | 
			
		||||
@lisp
 | 
			
		||||
(service power-profiles-daemon-service-type)
 | 
			
		||||
@end lisp
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@deftp {Data Type} power-profiles-daemon-configuration
 | 
			
		||||
Data type representing the configuration of @code{power-profiles-daemon-service-type}.
 | 
			
		||||
 | 
			
		||||
@table @asis
 | 
			
		||||
@item @code{power-profiles-daemon} (default: @code{power-profiles-daemon}) (type: file-like)
 | 
			
		||||
Package object of power-profiles-daemon.
 | 
			
		||||
 | 
			
		||||
@end table
 | 
			
		||||
@end deftp
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@cindex tlp
 | 
			
		||||
@cindex power management with TLP
 | 
			
		||||
@subsubheading TLP daemon
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
;;; GNU Guix --- Functional package management for GNU
 | 
			
		||||
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 | 
			
		||||
;;; Copyright © 2024 Dariqq <dariqq@posteo.net>
 | 
			
		||||
;;;
 | 
			
		||||
;;; This file is part of GNU Guix.
 | 
			
		||||
;;;
 | 
			
		||||
| 
						 | 
				
			
			@ -21,18 +22,75 @@
 | 
			
		|||
  #:use-module (guix packages)
 | 
			
		||||
  #:use-module (guix records)
 | 
			
		||||
  #:use-module (gnu packages admin)
 | 
			
		||||
  #:use-module (gnu packages freedesktop)
 | 
			
		||||
  #:use-module (gnu packages linux)
 | 
			
		||||
  #:use-module (gnu services)
 | 
			
		||||
  #:use-module (gnu services base)
 | 
			
		||||
  #:use-module (gnu services configuration)
 | 
			
		||||
  #:use-module (gnu services dbus)
 | 
			
		||||
  #:use-module (gnu services shepherd)
 | 
			
		||||
  #:use-module (gnu system shadow)
 | 
			
		||||
  #:export (tlp-service-type
 | 
			
		||||
  #:export (power-profiles-daemon-service-type
 | 
			
		||||
            power-profiles-daemon-configuration
 | 
			
		||||
 | 
			
		||||
            tlp-service-type
 | 
			
		||||
            tlp-configuration
 | 
			
		||||
 | 
			
		||||
            thermald-configuration
 | 
			
		||||
            thermald-service-type))
 | 
			
		||||
 | 
			
		||||
;;;
 | 
			
		||||
;;; power-profiles-daemon
 | 
			
		||||
;;;
 | 
			
		||||
 | 
			
		||||
(define-configuration/no-serialization power-profiles-daemon-configuration
 | 
			
		||||
  (power-profiles-daemon
 | 
			
		||||
   (file-like power-profiles-daemon)
 | 
			
		||||
   "The power-profiles-daemon package."))
 | 
			
		||||
 | 
			
		||||
(define (power-profiles-daemon-shepherd-service config)
 | 
			
		||||
  (match-record
 | 
			
		||||
      config <power-profiles-daemon-configuration>
 | 
			
		||||
      (power-profiles-daemon)
 | 
			
		||||
    (list (shepherd-service
 | 
			
		||||
           (provision '(power-profiles-daemon))
 | 
			
		||||
           (requirement '(dbus-system))
 | 
			
		||||
           (documentation "Run the power-profiles-daemon.")
 | 
			
		||||
           (start #~(make-forkexec-constructor
 | 
			
		||||
                     (list #$(file-append power-profiles-daemon
 | 
			
		||||
                                          "/libexec/power-profiles-daemon"))))
 | 
			
		||||
           (stop #~(make-kill-destructor))))))
 | 
			
		||||
 | 
			
		||||
(define %power-profiles-daemon-activation
 | 
			
		||||
  #~(begin
 | 
			
		||||
      (use-modules (guix build utils))
 | 
			
		||||
      (mkdir-p "/var/lib/power-profiles-daemon")))
 | 
			
		||||
 | 
			
		||||
(define power-profiles-daemon-service-type
 | 
			
		||||
  (let ((config->package
 | 
			
		||||
         (compose list power-profiles-daemon-configuration-power-profiles-daemon)))
 | 
			
		||||
    (service-type
 | 
			
		||||
     (name 'power-profiles-daemon)
 | 
			
		||||
     (extensions (list
 | 
			
		||||
                  (service-extension shepherd-root-service-type
 | 
			
		||||
                                     power-profiles-daemon-shepherd-service)
 | 
			
		||||
                  (service-extension dbus-root-service-type
 | 
			
		||||
                                     config->package)
 | 
			
		||||
                  (service-extension polkit-service-type
 | 
			
		||||
                                     config->package)
 | 
			
		||||
                  (service-extension profile-service-type
 | 
			
		||||
                                     config->package)
 | 
			
		||||
                  (service-extension activation-service-type
 | 
			
		||||
                                     (const %power-profiles-daemon-activation))))
 | 
			
		||||
     (default-value (power-profiles-daemon-configuration))
 | 
			
		||||
     (description "Run the power-profiles-daemon"))))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
;;;
 | 
			
		||||
;;; tlp
 | 
			
		||||
;;;
 | 
			
		||||
 | 
			
		||||
(define (uglify-field-name field-name)
 | 
			
		||||
  (let ((str (symbol->string field-name)))
 | 
			
		||||
    (string-join (string-split
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue