[PATCH 0/4] Update power-profiles-daemon and add a service-type for it.

  • Done
  • quality assurance status badge
Details
4 participants
  • Dariqq
  • Félix Baylac Jacqué
  • Ludovic Courtès
  • Christopher Baines
Owner
unassigned
Submitted by
Dariqq
Severity
normal
D
D
Dariqq wrote on 18 Apr 20:31 +0200
(address . guix-patches@gnu.org)(name . Dariqq)(address . dariqq@posteo.net)
cover.1713461694.git.dariqq@posteo.net
Hi Guix,

Here are a couple of patches that update the power-profiles-daemon to the latest release and add a corresponding service for it which will make changing power-profiles available in DEs like GNOME or via the cli tool.

I am not sure if some of the python dependencies should be normal inputs rather than native inputs.

The package will now also build the shell completions, manpage, docs and skip installing the systemd unit.
Also I was not sure if the gtk-docs should go to a seperate doc output but this corresponds to ~0.2 MB so I didn't bother.

The daemon is supposed to be a systemd unit started via dbus but just autostarting a similiar shepherd service seems fine as well and is what other distros without systemd do (i.e gentoo or void linux).

I've also tried to patch the dbus service definiton to run the daemon directly and it seems to work as well which would make the shepherd service obsolete. I am not sure what the better solution is.

The systemd unit specifies a 'conflict' with other power-management services like tlp but I don't think something similiar can be done for the shepherd right now.

The service-type is a rather simple and has the following extensions:
shepherd: Run the daemon.
dbus: Make the name of the service available.
polkit: Allow normal users to change power profile.
profile: Make the cli tool available.
activation: Create a directory.

As this is my first time writing a service-type any feedback would be greatly appreciated.

This would fix #69061.

Dariqq (4):
gnu: power-profiles-daemon: Update to 0.21.
gnu: power-profiles-daemon: Build gtk-docs.
gnu: power-profiles-daemon: Remove some (native) inputs.
gnu: services: Add power-profiles-daemon-service-type.

gnu/packages/freedesktop.scm | 45 ++++++++++++++++-------------
gnu/services/pm.scm | 56 +++++++++++++++++++++++++++++++++++-
2 files changed, 80 insertions(+), 21 deletions(-)


base-commit: 65e8472a4b6fc6f66871ba0dad518b7d4c63595e
--
2.41.0
D
D
Dariqq wrote on 18 Apr 20:36 +0200
[PATCH 2/4] gnu: power-profiles-daemon: Build gtk-docs.
(address . 70460@debbugs.gnu.org)(name . Dariqq)(address . dariqq@posteo.net)
84753be8c592076482e40d26ff4ccb9ccd3643c5.1713463209.git.dariqq@posteo.net
* gnu/packages/freedesktop.scm (power-profiles-daemon):
[#:configure-flags]: Enable building gtk-docs.
[inputs]: Add gtk-doc/stable, libxslt for docs.

Change-Id: I1bc6047858d2b5188e714f39da8b760bc6a71078
---
gnu/packages/freedesktop.scm | 3 +++
1 file changed, 3 insertions(+)

Toggle diff (24 lines)
diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index e30d9a218f..6ea5a70e21 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -1169,6 +1169,7 @@ (define-public power-profiles-daemon
(arguments
(list #:configure-flags #~(list "-Dsystemdsystemunitdir="
"-Dpylint=disabled"
+ "-Dgtk_doc=true"
(string-append "-Dzshcomp=" #$output
"/share/zsh/site-functions/"))
#:phases
@@ -1184,7 +1185,9 @@ (define-public power-profiles-daemon
`("GUIX_PYTHONPATH" = (,(getenv "GUIX_PYTHONPATH")))))))))
(native-inputs
(list `(,glib "bin")
+ gtk-doc/stable
gobject-introspection
+ libxslt
pkg-config
python
python-argparse-manpage
--
2.41.0
D
D
Dariqq wrote on 18 Apr 20:36 +0200
[PATCH 1/4] gnu: power-profiles-daemon: Update to 0.21.
(address . 70460@debbugs.gnu.org)(name . Dariqq)(address . dariqq@posteo.net)
be34e106723dbf8c2d6fc129f040c971b2bf728e.1713463209.git.dariqq@posteo.net
* gnu/packages/freedesktop (power-profiles-daemon): Update to 0.21.
[origin]<url>: Update repository url.
[homepage]: Update homepage.
[#:configure-flags]: Enable zsh completions, disable systemd-unit and
pylint.
[#:glib-or-gtk?]: Set to default value of #f.
[#:phases]<'fake-pkexec>: Remove phase, seems no longer necessary.
<'correct-polkit-dir>: Change to setting envvar instead.
<'wrap-program>: Remove GI_TYPELIB_PATH from wrapper.
[native-inputs]: Add python-argparse-manpage, python-dbusmock, python-shtab,
umockdev.
[inputs]: Add bash-completion.

Change-Id: I71220957ef6f4d224cc4c528562fe0565505aae1
---
gnu/packages/freedesktop.scm | 37 +++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)

Toggle diff (77 lines)
diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index 78443d6f5c..e30d9a218f 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -1154,40 +1154,47 @@ (define-public packagekit
(define-public power-profiles-daemon
(package
(name "power-profiles-daemon")
- (version "0.12")
+ (version "0.21")
(source
(origin
(method git-fetch)
(uri (git-reference
- (url "https://gitlab.freedesktop.org/hadess/power-profiles-daemon")
+ (url "https://gitlab.freedesktop.org/upower/power-profiles-daemon")
(commit version)))
(file-name (git-file-name name version))
(sha256
(base32
- "1wqcajbj358zpyj6y4h1v34y2yncq76wqxd0jm431habcly0bqyr"))))
+ "0dn3ygv49q7mzs52ch3yphxf4hbry698r1ajj52f6jgw7mpwr5p4"))))
(build-system meson-build-system)
(arguments
- (list #:configure-flags #~(list "-Dsystemdsystemunitdir=false")
- #:glib-or-gtk? #t
+ (list #:configure-flags #~(list "-Dsystemdsystemunitdir="
+ "-Dpylint=disabled"
+ (string-append "-Dzshcomp=" #$output
+ "/share/zsh/site-functions/"))
#:phases
#~(modify-phases %standard-phases
- (add-before 'install 'fake-pkexec
- (lambda _ (setenv "PKEXEC_UID" "-1")))
(add-before 'configure 'correct-polkit-dir
(lambda _
- (substitute* "meson.build"
- (("polkit_gobject_dep\\..*")
- (string-append "'" #$output "/share/polkit-1/actions'")))))
+ (setenv "PKG_CONFIG_POLKIT_GOBJECT_1_POLICYDIR"
+ (string-append #$output "/share/polkit-1/actions"))))
(add-after 'install 'wrap-program
(lambda _
(wrap-program
(string-append #$output "/bin/powerprofilesctl")
- `("GUIX_PYTHONPATH" = (,(getenv "GUIX_PYTHONPATH")))
- `("GI_TYPELIB_PATH" = (,(getenv "GI_TYPELIB_PATH")))))))))
+ `("GUIX_PYTHONPATH" = (,(getenv "GUIX_PYTHONPATH")))))))))
(native-inputs
- (list `(,glib "bin") gobject-introspection pkg-config python vala))
+ (list `(,glib "bin")
+ gobject-introspection
+ pkg-config
+ python
+ python-argparse-manpage
+ python-dbusmock
+ python-shtab
+ umockdev
+ vala))
(inputs
- (list bash-minimal ;for 'wrap-program'
+ (list bash-minimal ;for 'wrap-program'
+ bash-completion
dbus
dbus-glib
libgudev
@@ -1195,7 +1202,7 @@ (define-public power-profiles-daemon
python
python-pygobject
upower))
- (home-page "https://gitlab.freedesktop.org/hadess/power-profiles-daemon")
+ (home-page "https://gitlab.freedesktop.org/upower/power-profiles-daemon")
(synopsis "Power profile handling over D-Bus")
(description
"power-profiles-daemon offers to modify system behaviour based upon
--
2.41.0
D
D
Dariqq wrote on 18 Apr 20:36 +0200
[PATCH 3/4] gnu: power-profiles-daemon: Remove some (native) inputs.
(address . 70460@debbugs.gnu.org)(name . Dariqq)(address . dariqq@posteo.net)
092921f08ae2633f87379569d01fd7e8e50bf9e1.1713463209.git.dariqq@posteo.net
These don't seem necesary anymore.

* gnu/packages/freedesktop.scm (power-profiles-daemon):
[native-inputs]: Remove gobject-introspection, vala.
[inputs]: Remove dbus, dbus-glib, python, python-pygobjet.

Change-Id: I266d4d5d8da7ba3608f2b61726d81409a8a99cf8
---
gnu/packages/freedesktop.scm | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)

Toggle diff (34 lines)
diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index 6ea5a70e21..5ac90b7250 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -1186,24 +1186,19 @@ (define-public power-profiles-daemon
(native-inputs
(list `(,glib "bin")
gtk-doc/stable
- gobject-introspection
libxslt
pkg-config
python
python-argparse-manpage
python-dbusmock
python-shtab
- umockdev
- vala))
+ umockdev))
(inputs
(list bash-minimal ;for 'wrap-program'
bash-completion
- dbus
- dbus-glib
libgudev
- glib polkit
- python
- python-pygobject
+ glib
+ polkit
upower))
(home-page "https://gitlab.freedesktop.org/upower/power-profiles-daemon")
(synopsis "Power profile handling over D-Bus")
--
2.41.0
D
D
Dariqq wrote on 18 Apr 20:36 +0200
[PATCH 4/4] gnu: services: Add power-profiles-daemon-service-type.
(address . 70460@debbugs.gnu.org)(name . Dariqq)(address . dariqq@posteo.net)
09b1ed88b9e88d98b0b1df3ba3dd571da4a9b110.1713463209.git.dariqq@posteo.net
* gnu/services/pm.scm
(power-profiles-configuration): New configuration.
(power-profiles-daemon-shepherd-service): New function.
(power-profiles-daemon-service-type): New function.
(power-profiles-daemon-activation): New variable.

Change-Id: Ib035d993ed82eec2a43f3ba2b4c92f77e08a0fd7
---
gnu/services/pm.scm | 56 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)

Toggle diff (80 lines)
diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm
index 3daf484cc1..bedeebb9d8 100644
--- a/gnu/services/pm.scm
+++ b/gnu/services/pm.scm
@@ -21,18 +21,72 @@ (define-module (gnu services pm)
#: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
--
2.41.0
D
D
Dariqq wrote on 1 May 23:16 +0200
5b1c7841-6ca6-43fa-a238-38a2aa542517@posteo.net
Hi Félix,

On 01.05.24 18:43, Félix Baylac Jacqué wrote:
Toggle quote (7 lines)
> Hey Dariqq,
>
> Thanks for this!
>
> I would like to bump this patchset in the hope it catches the attention
> of a maintainer. It sadly do not apply cleanly on current master
> anymore.
There some issues that qa is unable to build the package on x86_64 due
to tests timing out (and possibly other problems with tests?).

See

It seems fine for aarch64 and powerpc64le.

I am not really sure what's causing this as the tests are all fine for
me locally. Maybe increasing the timeout window in the tests could
improve this?
Toggle quote (10 lines)
>
> This daemon is pretty important for laptops. This is the daemon used to
> tune the CPU power efficiency by multiple DE: Gnome, KDE, Waybar, and
> likely others I'm not aware of.
>
> Power-profiles-daemon is meant to be launched as a system service, not
> by dbus itself. This patchset is crutial to get a functional
> power-profiles-daemon setup.
>

Great. The dbus service acts then just as a dummy to make the name
available.

Toggle quote (4 lines)
> I'm also a Guix rookie, so I can't really help wrt. the service
> definitions best practices.
>

I also forgot include a short documentation for the service in
doc/guix.texi. I have not yet looked into writing texinfo manuals but
hopefully will get to do that later this week.

Toggle quote (5 lines)
> I maintain this package on NixOS, I have a bit of experience with it,
> and the packaging part looks fine overall. I'm not 100% sure generating
> the gtk-doc is worth the closure size increase, but I think it's fine
> for now, it shouldn't be a show-stopper.

I guess I could move them to a seperate output. Though this does not
address closure size.
Toggle quote (4 lines)
>
> I'm using this patchset on my system, it works as intended, it'd be
> great to see it merged.

Awesome.
Toggle quote (4 lines)
>
> What should we do to get this moving forward? I'm up to help in the
> process if neccessary.

I'd say fixing the build on the build farm, adding the missing manual
entry and getting the attention of someone who knows more about services.
F
F
Félix Baylac Jacqué wrote on 1 May 18:43 +0200
87wmod1o0k.fsf@alternativebit.fr
Hey Dariqq,

Thanks for this!

I would like to bump this patchset in the hope it catches the attention
of a maintainer. It sadly do not apply cleanly on current master
anymore.

This daemon is pretty important for laptops. This is the daemon used to
tune the CPU power efficiency by multiple DE: Gnome, KDE, Waybar, and
likely others I'm not aware of.

Power-profiles-daemon is meant to be launched as a system service, not
by dbus itself. This patchset is crutial to get a functional
power-profiles-daemon setup.

I'm also a Guix rookie, so I can't really help wrt. the service
definitions best practices.

I maintain this package on NixOS, I have a bit of experience with it,
and the packaging part looks fine overall. I'm not 100% sure generating
the gtk-doc is worth the closure size increase, but I think it's fine
for now, it shouldn't be a show-stopper.

I'm using this patchset on my system, it works as intended, it'd be
great to see it merged.

What should we do to get this moving forward? I'm up to help in the
process if neccessary.
D
D
Dariqq wrote on 2 May 17:37 +0200
[PATCH v2 2/3] gnu: power-profiles-daemon: Build gtk-docs.
(address . 70460@debbugs.gnu.org)
96f7ba672aea10b1c259bba52d0536b3ce87aa38.1714662236.git.dariqq@posteo.net
* gnu/packages/freedesktop.scm (power-profiles-daemon):
[outputs]: Add docs output.
[#:configure-flags]: Enable building gtk-docs.
[#:phases]: Add a phase to move gtk-docs to docs output.
[inputs]: Add gtk-doc/stable, libxslt for docs.

Change-Id: I1bc6047858d2b5188e714f39da8b760bc6a71078
---
gnu/packages/freedesktop.scm | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

Toggle diff (37 lines)
diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index 53cae544aa..a77dab5794 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -1169,9 +1169,11 @@ (define-public power-profiles-daemon
(base32
"0dn3ygv49q7mzs52ch3yphxf4hbry698r1ajj52f6jgw7mpwr5p4"))))
(build-system meson-build-system)
+ (outputs '("out" "doc"))
(arguments
(list #:configure-flags #~(list "-Dsystemdsystemunitdir="
"-Dpylint=disabled"
+ "-Dgtk_doc=true"
(string-append "-Dzshcomp=" #$output
"/share/zsh/site-functions/"))
#:phases
@@ -1189,9 +1191,17 @@ (define-public power-profiles-daemon
"/lib/python"
#$(version-major+minor
(package-version (this-package-input "python")))
- "/site-packages")))))))))
+ "/site-packages"))))))
+ (add-after 'install 'move-docs
+ (lambda _
+ (mkdir-p (string-append #$output:doc "/share"))
+ (rename-file
+ (string-append #$output "/share/gtk-doc")
+ (string-append #$output:doc "/share/gtk-doc")))))))
(native-inputs
(list `(,glib "bin")
+ gtk-doc/stable
+ libxslt
pkg-config
python
python-argparse-manpage
--
2.41.0
D
D
Dariqq wrote on 2 May 17:37 +0200
[PATCH v2 0/3] Update power-profiles-daemon and add a service-type for it.
(address . 70460@debbugs.gnu.org)
cover.1714662236.git.dariqq@posteo.net
Hi all,

Here is v2 of the patches.

I hope the added manual entry is ok as I don't have prior experience writing texinfo. I've added the note not to use tlp and p-p-d together there too.

Also is there a better way to set the pythonpath to not include the packages in native-inputs? This decreases guix size of the package by 100 MB.

Changes compared to v1:

* Added the commit removing inputs to the first commit.
* Added back python and python-pygobject as inputs (previously propagated from python-dbusmock in native-inputs).
* Set GUIX_PYTHONPATH to only refer to nonnative python inputs rather than all.
* Moved gtk-docs to a seperate doc output.
* Added a short entry in the manual for the service-type.
* Added my copyright line in all files.

Things that could still be improved:
* The generated manpage looks horrible because python-argparse-manpage is outdated. I've tried updating it but ran into test errors.
* Test timeout issues on qa? I am not sure what to do here as it is kind of hard for me to guess what an appropriate timeout window would be that would work.


Dariqq (3):
gnu: power-profiles-daemon: Update to 0.21.
gnu: power-profiles-daemon: Build gtk-docs.
gnu: services: Add power-profiles-daemon-service-type.

doc/guix.texi | 40 +++++++++++++++++++++++++
gnu/packages/freedesktop.scm | 56 +++++++++++++++++++++++------------
gnu/services/pm.scm | 57 +++++++++++++++++++++++++++++++++++-
3 files changed, 134 insertions(+), 19 deletions(-)


base-commit: 5010a51fc91aeac5a3b87a3eea04f18f3fe8a3a3
--
2.41.0
D
D
Dariqq wrote on 2 May 17:37 +0200
[PATCH v2 3/3] gnu: services: Add power-profiles-daemon-service-type.
(address . 70460@debbugs.gnu.org)
d918418934ba19da07cd922c677a88bb68d2c31a.1714662236.git.dariqq@posteo.net
* 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
---
doc/guix.texi | 40 +++++++++++++++++++++++++++++++
gnu/services/pm.scm | 57 ++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 96 insertions(+), 1 deletion(-)

Toggle diff (145 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 749d689ac1..533715fd91 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -127,6 +127,7 @@
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
@@ -34669,6 +34670,45 @@ Continuous Integration
@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
diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm
index 3daf484cc1..33d2c07367 100644
--- a/gnu/services/pm.scm
+++ b/gnu/services/pm.scm
@@ -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,72 @@ (define-module (gnu services pm)
#: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
--
2.41.0
D
D
Dariqq wrote on 2 May 17:37 +0200
[PATCH v2 1/3] gnu: power-profiles-daemon: Update to 0.21.
(address . 70460@debbugs.gnu.org)
93424f8c765f0d3188e00792738653016b9a992d.1714662236.git.dariqq@posteo.net
* gnu/packages/freedesktop (power-profiles-daemon): Update to 0.21.
[origin]<url>: Update repository url.
[homepage]: Update homepage.
[#:configure-flags]: Enable zsh completions, disable systemd-unit and
pylint.
[#:glib-or-gtk?]: Set to default value of #f.
[#:phases]<'fake-pkexec>: Remove phase, seems no longer necessary.
<'correct-polkit-dir>: Change to setting envvar instead.
<'wrap-program>: Remove GI_TYPELIB_PATH from wrapper. Remove native python
inputs from PYTHONPATH.
[native-inputs]: Add python-argparse-manpage, python-dbusmock, python-shtab,
umockdev. Remove gobject-introspection, vala.
[inputs]: Add bash-completion. Remove dbus, dbus-glib.

Change-Id: I71220957ef6f4d224cc4c528562fe0565505aae1
---
gnu/packages/freedesktop.scm | 46 ++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 18 deletions(-)

Toggle diff (90 lines)
diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index 081269ebaf..53cae544aa 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -37,6 +37,7 @@
;;; Copyright © 2024 Zheng Junjie <873216071@qq.com>
;;; Copyright © 2022 Samuel Culpepper <sculpepper@newstore.com>
;;; Copyright © 2024 aurtzy <aurtzy@gmail.com>
+;;; Copyright © 2024 Dariqq <dariqq@posteo.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1156,48 +1157,57 @@ (define-public packagekit
(define-public power-profiles-daemon
(package
(name "power-profiles-daemon")
- (version "0.12")
+ (version "0.21")
(source
(origin
(method git-fetch)
(uri (git-reference
- (url "https://gitlab.freedesktop.org/hadess/power-profiles-daemon")
+ (url "https://gitlab.freedesktop.org/upower/power-profiles-daemon")
(commit version)))
(file-name (git-file-name name version))
(sha256
(base32
- "1wqcajbj358zpyj6y4h1v34y2yncq76wqxd0jm431habcly0bqyr"))))
+ "0dn3ygv49q7mzs52ch3yphxf4hbry698r1ajj52f6jgw7mpwr5p4"))))
(build-system meson-build-system)
(arguments
- (list #:configure-flags #~(list "-Dsystemdsystemunitdir=false")
- #:glib-or-gtk? #t
+ (list #:configure-flags #~(list "-Dsystemdsystemunitdir="
+ "-Dpylint=disabled"
+ (string-append "-Dzshcomp=" #$output
+ "/share/zsh/site-functions/"))
#:phases
#~(modify-phases %standard-phases
- (add-before 'install 'fake-pkexec
- (lambda _ (setenv "PKEXEC_UID" "-1")))
(add-before 'configure 'correct-polkit-dir
(lambda _
- (substitute* "meson.build"
- (("polkit_gobject_dep\\..*")
- (string-append "'" #$output "/share/polkit-1/actions'")))))
+ (setenv "PKG_CONFIG_POLKIT_GOBJECT_1_POLICYDIR"
+ (string-append #$output "/share/polkit-1/actions"))))
(add-after 'install 'wrap-program
(lambda _
(wrap-program
(string-append #$output "/bin/powerprofilesctl")
- `("GUIX_PYTHONPATH" = (,(getenv "GUIX_PYTHONPATH")))
- `("GI_TYPELIB_PATH" = (,(getenv "GI_TYPELIB_PATH")))))))))
+ `("GUIX_PYTHONPATH" = (,(string-append
+ #$(this-package-input "python-pygobject")
+ "/lib/python"
+ #$(version-major+minor
+ (package-version (this-package-input "python")))
+ "/site-packages")))))))))
(native-inputs
- (list `(,glib "bin") gobject-introspection pkg-config python vala))
+ (list `(,glib "bin")
+ pkg-config
+ python
+ python-argparse-manpage
+ python-dbusmock
+ python-shtab
+ umockdev))
(inputs
- (list bash-minimal ;for 'wrap-program'
- dbus
- dbus-glib
+ (list bash-minimal ;for 'wrap-program'
+ bash-completion
libgudev
- glib polkit
+ glib
+ polkit
python
python-pygobject
upower))
- (home-page "https://gitlab.freedesktop.org/hadess/power-profiles-daemon")
+ (home-page "https://gitlab.freedesktop.org/upower/power-profiles-daemon")
(synopsis "Power profile handling over D-Bus")
(description
"power-profiles-daemon offers to modify system behaviour based upon
--
2.41.0
D
D
Dariqq wrote on 9 May 10:00 +0200
Re: [PATCH v2 0/3] Update power-profiles-daemon and add a service-type for it.
(address . 70460@debbugs.gnu.org)(address . felix@alternativebit.fr)
ef702260-e612-4b5b-bf76-b9d8a46e4679@posteo.net
On 02.05.24 17:37, Dariqq wrote:
Toggle quote (20 lines)
> Hi all,
>
> Here is v2 of the patches.
>
> I hope the added manual entry is ok as I don't have prior experience writing texinfo. I've added the note not to use tlp and p-p-d together there too.
>
> Also is there a better way to set the pythonpath to not include the packages in native-inputs? This decreases guix size of the package by 100 MB.
>
> Changes compared to v1:
>
> * Added the commit removing inputs to the first commit.
> * Added back python and python-pygobject as inputs (previously propagated from python-dbusmock in native-inputs).
> * Set GUIX_PYTHONPATH to only refer to nonnative python inputs rather than all.
> * Moved gtk-docs to a seperate doc output.
> * Added a short entry in the manual for the service-type.
> * Added my copyright line in all files.
>
> Things that could still be improved:
> * The generated manpage looks horrible because python-argparse-manpage is outdated. I've tried updating it but ran into test errors.

For the manpage I've updated python-argparse-manpage in #70834 which got
pushed yesterday which fixes the manpage for me locally.


Toggle quote (4 lines)
> * Test timeout issues on qa? I am not sure what to do here as it is kind of hard for me to guess what an appropriate timeout window would be that would work.
>
>

It seems to succeeding now. Maybe we just got lucky this time?

Toggle quote (12 lines)
> Dariqq (3):
> gnu: power-profiles-daemon: Update to 0.21.
> gnu: power-profiles-daemon: Build gtk-docs.
> gnu: services: Add power-profiles-daemon-service-type.
>
> doc/guix.texi | 40 +++++++++++++++++++++++++
> gnu/packages/freedesktop.scm | 56 +++++++++++++++++++++++------------
> gnu/services/pm.scm | 57 +++++++++++++++++++++++++++++++++++-
> 3 files changed, 134 insertions(+), 19 deletions(-)
>
>
> base-commit: 5010a51fc91aeac5a3b87a3eea04f18f3fe8a3a3
C
C
Christopher Baines wrote on 16 May 08:55 +0200
Re: [bug#70460] [PATCH v2 0/3] Update power-profiles-daemon and add a service-type for it.
(name . Dariqq)(address . dariqq@posteo.net)
871q62p7o4.fsf@cbaines.net
Dariqq <dariqq@posteo.net> writes:

Toggle quote (12 lines)
> Hi all,
>
> Here is v2 of the patches.
>
> I hope the added manual entry is ok as I don't have prior experience
> writing texinfo. I've added the note not to use tlp and p-p-d together
> there too.
>
> Also is there a better way to set the pythonpath to not include the
> packages in native-inputs? This decreases guix size of the package by
> 100 MB.

...

Toggle quote (18 lines)
> Things that could still be improved:
> * The generated manpage looks horrible because python-argparse-manpage
> is outdated. I've tried updating it but ran into test errors.
> * Test timeout issues on qa? I am not sure what to do here as it is
> kind of hard for me to guess what an appropriate timeout window would
> be that would work.
>
>
> Dariqq (3):
> gnu: power-profiles-daemon: Update to 0.21.
> gnu: power-profiles-daemon: Build gtk-docs.
> gnu: services: Add power-profiles-daemon-service-type.
>
> doc/guix.texi | 40 +++++++++++++++++++++++++
> gnu/packages/freedesktop.scm | 56 +++++++++++++++++++++++------------
> gnu/services/pm.scm | 57 +++++++++++++++++++++++++++++++++++-
> 3 files changed, 134 insertions(+), 19 deletions(-)

Thanks both, these patches look good to me. I removed some tabs and
tweaked some indentation and pushed these to master as
d0ad4f557fc8b9d105877f2ef4de0ce12c5c9566.

Chris
-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmZFretfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9Xdq7A//QsyGGaYy5t5ZG/FZKsK9XpNFrjua3HfB
ZAWGX8NjL64f6eJWevAcsB2qtmzlwf7divvVoDaHUhwSIJ3eCLuCUAejc9F+U3C+
6Y9cGlpM0XJlG7ERfQdtsgMSg5yxuflmYJVHSih0WF430tNE64wBSIkGwCHuPGDP
n/yMPWA/wOvuWfBwD+6a1L2i9DYU7SjIxRID6/fugvktzYJcO/lF/cFlqcU+ukvZ
HiBUMxT6cKAe/dw52zIdiMbAymNhuDY1O7SsqIHzeKdSZbQe4Uhn3HKLO4A7seBu
GVHAj7z66RR4CDH7q6xBAHKQNzE2UE4L9MXTrRj0LJN3VQCB14als1Lo2nG9sC4L
A0DTK2FJlPPcXbjfs2Lecaxcjznv+rOk5T6+284OwUDOSRiMV/1oi0LBr2ZNFOYE
JkfLlRagh7zFJA/w+BfwTrk5pcaeba1W39E4sOzG+L2BOdo+1KTZssLePFucF2Zl
aG3zxqzG2QhLQREtwTYu41xCF1ifq5Riag+GrmxWlk+ypPR1jUsRUw1Paxt2xkIv
THryjeC3UVy9KtTQcNOpu2Q6MPCguzos/WRjLt8iXrCa/ECDHEMpEExm5EFIByEt
Y3cbMIciu4iHLVTMkfP3SXaXVFEh+kEjkIrWHG30HXZXqUBSMxj6W0Ew2Z3Hnoe9
tXHW5n4hinc=
=/mhB
-----END PGP SIGNATURE-----

Closed
L
L
Ludovic Courtès wrote 2 days ago
Re: [bug#70460] [PATCH v2 3/3] gnu: services: Add power-profiles-daemon-service-type.
(name . Dariqq)(address . dariqq@posteo.net)
87msoe10l1.fsf@gnu.org
Hi!

Dariqq <dariqq@posteo.net> skribis:

Toggle quote (9 lines)
> * 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

[…]

Toggle quote (4 lines)
> +@quotation Important
> +The @code{power-profiles-daemon} conflicts with other power management tools
> +like @code{tlp}. Using both together is not recommended.

s/like/such as/
s/Using.*/Pick one or the other./

What about UPower? Do I get it right that this actually builds upon
UPower?

Should it say a word about how it defers from TLP?

Toggle quote (7 lines)
> +(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))

Rather: (requirement '(user-processes dbus-system)).

Toggle quote (2 lines)
> + (documentation "Run the power-profiles-daemon.")

Nitpick: “Run the Power Profiles Daemon”.

Also please indent this procedure similar to how this is done elsewhere.

Toggle quote (2 lines)
> + (description "Run the power-profiles-daemon"))))

Same as above. :-)

Thanks!

Ludo’.
D
D
Dariqq wrote 2 days ago
(name . Ludovic Courtès)(address . ludo@gnu.org)
b69edffc-4090-44f3-ba08-d312633f9bc0@posteo.net
Hi Ludo,

Thanks for the feedback. As this was pushed to master last week i am
unsure how to incorporate it.

On 25.05.24 15:29, Ludovic Courtès wrote:
Toggle quote (26 lines)
> Hi!
>
> Dariqq <dariqq@posteo.net> skribis:
>
>> * 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
>
> […]
>
>> +@quotation Important
>> +The @code{power-profiles-daemon} conflicts with other power management tools
>> +like @code{tlp}. Using both together is not recommended.
>
> s/like/such as/
> s/Using.*/Pick one or the other./
>
> What about UPower? Do I get it right that this actually builds upon
> UPower?
>

This comment is based on the information from
The systemd unit file specifies a conflict with tuned.service,
tlp.service, auto-cpufreq.service and system76-power.service and I was
not sure how to communicate this other with a big warning in the
documentation.

Another option I thought about since then was to make p-p-d and tlp
also provide a generic power-management name (suggestions for a better
name are welcome) similiar to what is done with login-mangers providing
xorg-server such that shepherd will not allow both at the same time.


Toggle quote (2 lines)
> Should it say a word about how it defers from TLP?

Skimming through the tlp documentation
main points seem to be:

- tlp is more customizable offering more (potentially destructive)
options and fine-grained control
- p-p-d is more generic and with the integrations in DEs like GNOME,
KDE, etc easier to use for normal desktop users.
Toggle quote (23 lines)
>
>> +(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))
>
> Rather: (requirement '(user-processes dbus-system)).
>
>> + (documentation "Run the power-profiles-daemon.")
>
> Nitpick: “Run the Power Profiles Daemon”.
>
> Also please indent this procedure similar to how this is done elsewhere.
>
>> + (description "Run the power-profiles-daemon"))))
>
> Same as above. :-)
>
> Thanks!
>
> Ludo’.
?