From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id IK1wA0u0M2bjZQEA62LTzQ:P1 (envelope-from ) for ; Thu, 02 May 2024 17:42:03 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id IK1wA0u0M2bjZQEA62LTzQ (envelope-from ) for ; Thu, 02 May 2024 17:42:03 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=qObNM99p; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1714664522; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=RLMuu950hEy3IkbDIizZaA8wUm2NgvRJxsMGoZYaITg=; b=iKap4Pc6/ayvHF3/ushKEgN0EZ6/bb5tVqmh4k6qqWUYj7/rdFcQZO6hYzXoXre3udZsMx rystFWB3iCmP6L8pIknqx+znmUoLr2tWJTrOZQ1lWmQPinynMIDCk1EhURcHSASd7uWEej Kmb8/9CeYS5AadQegUiMyrORDoIUnjs9nyANDkAiSVv48H+IrkAiCX7kbE7swhk7peRyqU XyhMlK41KOQvchlab49diDafZmhyzyBT2GfQOU81EdNq3Ff9sn+0z24vvh4in/L6zCgLwD i3HV8RBteV1P1f9CKpL5tTay5ON3YWhpuov3ylMLcZiasFBbuLyNwTUOXN0aKA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=qObNM99p; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1714664522; a=rsa-sha256; cv=none; b=G+pqpxZz5GOnuWvfVzbSpTtCKu3Nnl0LaI6VNTZu4qEUeEwVR1/lXdtL5dh9i8lgMBgkrr 6+duU03tETQpint971cXpvY4f6z88aAQDvUxeN6iNrqQngXOHXLOSL8cE/vaK3NB3ywXWV gQEOWLiZr/Pu3TQGRTypO9AzfzfAm5yDg6w+meAWCox9csiXS9HqhR4BhQmp8Sf9ww7U/T o6FlozXTT1On8x9DZiwVdK+EDsptzd12ca3r1lqi3crdLuvH6ZToACjOCYld1+MAi5yvBb irxh1WjGSPQsGtgr5VXOZpNFBVO2C9WPQ+qyyJdtyAKSr7v6zHwVWegPZ1d96Q== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9783969D05 for ; Thu, 2 May 2024 17:42:02 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2YZ6-0004ci-TB; Thu, 02 May 2024 11:41:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2YZ3-0004Zo-I3 for guix-patches@gnu.org; Thu, 02 May 2024 11:41:42 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2YZ2-0000LT-Ux; Thu, 02 May 2024 11:41:41 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s2YZO-0007T9-PJ; Thu, 02 May 2024 11:42:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70460] [PATCH v2 3/3] gnu: services: Add power-profiles-daemon-service-type. Resent-From: Dariqq Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, guix-patches@gnu.org Resent-Date: Thu, 02 May 2024 15:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70460 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70460@debbugs.gnu.org Cc: Dariqq , felix@alternativebit.fr, Florian Pelz , Ludovic =?UTF-8?Q?Court=C3=A8s?= X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 70460-submit@debbugs.gnu.org id=B70460.171466451428678 (code B ref 70460); Thu, 02 May 2024 15:42:02 +0000 Received: (at 70460) by debbugs.gnu.org; 2 May 2024 15:41:54 +0000 Received: from localhost ([127.0.0.1]:44520 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2YZF-0007SP-Qm for submit@debbugs.gnu.org; Thu, 02 May 2024 11:41:54 -0400 Received: from mout01.posteo.de ([185.67.36.65]:45825) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2YZD-0007Rq-0f for 70460@debbugs.gnu.org; Thu, 02 May 2024 11:41:52 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 86B0B24002A for <70460@debbugs.gnu.org>; Thu, 2 May 2024 17:41:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1714664483; bh=HRDb1ofAPDVKixJ/E3icIgs2mdpTxStgLm3ExTsruro=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=qObNM99paPOZujUiMSEf8hPDGlkYxNTDdui8kn4FWqJFn1SyPuF9UMf1ZEiTWI1JV GOIgwPb7XzVxp+okz9L+6kdbOHJz7XC1Ol+ircRqR1zLYBZLx8TWOU/lM+xz1e/DtG B3L0fNFcCDTRC5hNva5v6W/yH7mG8c/Kt/E69fTX4X+8T4+RfkCSSWRjgYOIR7n3Ur DQ6cWaDN8ZpXOZYP7WN7tCrPaDXn9/N+3V+HHGISkcvgKj6naPBWmOd9e9RUosA2Ap 7bEZ/cW0s+63nM4I3qi1zxk01eZFnOsvjsXUYkDx7rcmx4+GuUkTTFtsXav5x+7I6u Hix7h1+dHTLoA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VVdSy6Vymz6twr; Thu, 2 May 2024 17:41:22 +0200 (CEST) From: Dariqq Date: Thu, 2 May 2024 15:37:56 +0000 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: 3.41 X-Migadu-Queue-Id: 9783969D05 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: 3.41 X-TUID: MFOoxWJxzaXN * 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 +;;; Copyright © 2024 Dariqq ;;; ;;; 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) + (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