GNU bug report logs - #70460
[PATCH 0/4] Update power-profiles-daemon and add a service-type for it.

Previous Next

Package: guix-patches;

Reported by: Dariqq <dariqq <at> posteo.net>

Date: Thu, 18 Apr 2024 18:35:03 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 70460 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#70460; Package guix-patches. (Thu, 18 Apr 2024 18:35:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dariqq <dariqq <at> posteo.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 18 Apr 2024 18:35:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dariqq <dariqq <at> posteo.net>
To: guix-patches <at> gnu.org
Cc: Dariqq <dariqq <at> posteo.net>
Subject: [PATCH 0/4] Update power-profiles-daemon and add a service-type for
 it.
Date: Thu, 18 Apr 2024 18:31:10 +0000
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





Information forwarded to guix-patches <at> gnu.org:
bug#70460; Package guix-patches. (Thu, 18 Apr 2024 18:38:02 GMT) Full text and rfc822 format available.

Message #8 received at 70460 <at> debbugs.gnu.org (full text, mbox):

From: Dariqq <dariqq <at> posteo.net>
To: 70460 <at> debbugs.gnu.org
Cc: Dariqq <dariqq <at> posteo.net>
Subject: [PATCH 2/4] gnu: power-profiles-daemon: Build gtk-docs.
Date: Thu, 18 Apr 2024 18:36:02 +0000
* 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(+)

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





Information forwarded to guix-patches <at> gnu.org:
bug#70460; Package guix-patches. (Thu, 18 Apr 2024 18:38:03 GMT) Full text and rfc822 format available.

Message #11 received at 70460 <at> debbugs.gnu.org (full text, mbox):

From: Dariqq <dariqq <at> posteo.net>
To: 70460 <at> debbugs.gnu.org
Cc: Dariqq <dariqq <at> posteo.net>
Subject: [PATCH 1/4] gnu: power-profiles-daemon: Update to 0.21.
Date: Thu, 18 Apr 2024 18:36:01 +0000
* 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(-)

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





Information forwarded to guix-patches <at> gnu.org:
bug#70460; Package guix-patches. (Thu, 18 Apr 2024 18:38:03 GMT) Full text and rfc822 format available.

Message #14 received at 70460 <at> debbugs.gnu.org (full text, mbox):

From: Dariqq <dariqq <at> posteo.net>
To: 70460 <at> debbugs.gnu.org
Cc: Dariqq <dariqq <at> posteo.net>
Subject: [PATCH 3/4] gnu: power-profiles-daemon: Remove some (native) inputs.
Date: Thu, 18 Apr 2024 18:36:03 +0000
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(-)

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





Information forwarded to guix-patches <at> gnu.org:
bug#70460; Package guix-patches. (Thu, 18 Apr 2024 18:38:04 GMT) Full text and rfc822 format available.

Message #17 received at 70460 <at> debbugs.gnu.org (full text, mbox):

From: Dariqq <dariqq <at> posteo.net>
To: 70460 <at> debbugs.gnu.org
Cc: Dariqq <dariqq <at> posteo.net>
Subject: [PATCH 4/4] gnu: services: Add power-profiles-daemon-service-type.
Date: Thu, 18 Apr 2024 18:36:04 +0000
* 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(-)

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





Information forwarded to guix-patches <at> gnu.org:
bug#70460; Package guix-patches. (Wed, 01 May 2024 21:18:02 GMT) Full text and rfc822 format available.

Message #20 received at 70460 <at> debbugs.gnu.org (full text, mbox):

From: Dariqq <dariqq <at> posteo.net>
To: Félix Baylac Jacqué <felix <at> alternativebit.fr>,
 70460 <at> debbugs.gnu.org
Subject: Re: [bug#70460] [PATCH 4/4] gnu: services: Add
 power-profiles-daemon-service-type.
Date: Wed,  1 May 2024 21:16:39 +0000
Hi Félix,

On 01.05.24 18:43, Félix Baylac Jacqué wrote:
> 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 
https://data.qa.guix.gnu.org/gnu/store/5h0j710311kcz9hz87dznz97xirfzgpx-power-profiles-daemon-0.21.drv.

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?
> 
> 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.

> 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.

> 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.
> 
> I'm using this patchset on my system, it works as intended, it'd be
> great to see it merged.

Awesome.
> 
> 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.




Information forwarded to guix-patches <at> gnu.org:
bug#70460; Package guix-patches. (Thu, 02 May 2024 04:41:02 GMT) Full text and rfc822 format available.

Message #23 received at 70460 <at> debbugs.gnu.org (full text, mbox):

From: Félix Baylac Jacqué
 <felix <at> alternativebit.fr>
To: Dariqq <dariqq <at> posteo.net>, 70460 <at> debbugs.gnu.org
Subject: Re: [bug#70460] [PATCH 4/4] gnu: services: Add
 power-profiles-daemon-service-type.
Date: Wed, 01 May 2024 18:43:23 +0200
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.




Information forwarded to guix-patches <at> gnu.org:
bug#70460; Package guix-patches. (Thu, 02 May 2024 15:42:01 GMT) Full text and rfc822 format available.

Message #26 received at 70460 <at> debbugs.gnu.org (full text, mbox):

From: Dariqq <dariqq <at> posteo.net>
To: 70460 <at> debbugs.gnu.org
Cc: Dariqq <dariqq <at> posteo.net>, felix <at> alternativebit.fr
Subject: [PATCH v2 2/3] gnu: power-profiles-daemon: Build gtk-docs.
Date: Thu,  2 May 2024 15:37:55 +0000
* 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(-)

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





Information forwarded to pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, guix-patches <at> gnu.org:
bug#70460; Package guix-patches. (Thu, 02 May 2024 15:42:02 GMT) Full text and rfc822 format available.

Message #29 received at 70460 <at> debbugs.gnu.org (full text, mbox):

From: Dariqq <dariqq <at> posteo.net>
To: 70460 <at> debbugs.gnu.org
Cc: Dariqq <dariqq <at> posteo.net>, felix <at> alternativebit.fr
Subject: [PATCH v2 0/3] Update power-profiles-daemon and add a service-type
 for it.
Date: Thu,  2 May 2024 15:37:53 +0000
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





Information forwarded to pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, guix-patches <at> gnu.org:
bug#70460; Package guix-patches. (Thu, 02 May 2024 15:42:02 GMT) Full text and rfc822 format available.

Message #32 received at 70460 <at> debbugs.gnu.org (full text, mbox):

From: Dariqq <dariqq <at> posteo.net>
To: 70460 <at> debbugs.gnu.org
Cc: Dariqq <dariqq <at> posteo.net>, felix <at> alternativebit.fr
Subject: [PATCH v2 3/3] gnu: services: Add power-profiles-daemon-service-type.
Date: Thu,  2 May 2024 15:37:56 +0000
* 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(-)

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 <at> gmail.com>
+;;; Copyright © 2024 Dariqq <dariqq <at> 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





Information forwarded to guix-patches <at> gnu.org:
bug#70460; Package guix-patches. (Thu, 02 May 2024 15:42:03 GMT) Full text and rfc822 format available.

Message #35 received at 70460 <at> debbugs.gnu.org (full text, mbox):

From: Dariqq <dariqq <at> posteo.net>
To: 70460 <at> debbugs.gnu.org
Cc: Dariqq <dariqq <at> posteo.net>, felix <at> alternativebit.fr
Subject: [PATCH v2 1/3] gnu: power-profiles-daemon: Update to 0.21.
Date: Thu,  2 May 2024 15:37:54 +0000
* 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(-)

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 <at> qq.com>
 ;;; Copyright © 2022 Samuel Culpepper <sculpepper <at> newstore.com>
 ;;; Copyright © 2024 aurtzy <aurtzy <at> gmail.com>
+;;; Copyright © 2024 Dariqq <dariqq <at> 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





This bug report was last modified 2 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.