X-Loop: help-debbugs@HIDDEN Subject: [bug#75528] [PATCH 0/2] Add apcupsd Resent-From: Tomas Volf <~@wolfsden.cz> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: ludo@HIDDEN, maxim.cournoyer@HIDDEN, guix-patches@HIDDEN Resent-Date: Sun, 12 Jan 2025 23:04:01 +0000 Resent-Message-ID: <handler.75528.B.173672302126859 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 75528 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75528 <at> debbugs.gnu.org Cc: Tomas Volf <~@wolfsden.cz>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN> X-Debbugs-Original-To: guix-patches@HIDDEN X-Debbugs-Original-Xcc: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN> Received: via spool by submit <at> debbugs.gnu.org id=B.173672302126859 (code B ref -1); Sun, 12 Jan 2025 23:04:01 +0000 Received: (at submit) by debbugs.gnu.org; 12 Jan 2025 23:03:41 +0000 Received: from localhost ([127.0.0.1]:49434 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tX6zc-0006z7-Ry for submit <at> debbugs.gnu.org; Sun, 12 Jan 2025 18:03:41 -0500 Received: from lists.gnu.org ([2001:470:142::17]:51028) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1tX6za-0006yr-FH for submit <at> debbugs.gnu.org; Sun, 12 Jan 2025 18:03:38 -0500 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 <~@wolfsden.cz>) id 1tX6zT-0002Y6-RM for guix-patches@HIDDEN; Sun, 12 Jan 2025 18:03:31 -0500 Received: from wolfsden.cz ([37.205.8.62]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <~@wolfsden.cz>) id 1tX6zR-0002AL-Oa for guix-patches@HIDDEN; Sun, 12 Jan 2025 18:03:31 -0500 Received: by wolfsden.cz (Postfix, from userid 104) id A3BE0342D88; Sun, 12 Jan 2025 23:03:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1736723004; bh=cGFxvdC/c6T4ddXl9L2OjLona+t5z0KhM0b5+IkJrd4=; h=From:To:Cc:Subject:Date; b=T4BAGAN1qTkucn2r7VNbyzaPRZv2bf0/vKSoqmJOnIUWGlwXyHr47FSa5jiicHhou VXAvq6YPA2LFmb4czk4ocynK/wg/z/WHY32i/1GEoWznQAlRZ6BDk9KuxaLOPLA+eY rGOefqaMyl4ML8LycxB2PddRlaQ20Szkmh4L2gfrjqXyh/XsWbKo0+hNwmMTg4siji ZlEBtn1FYAwVMFEzDrQJVa1kRg29j4m78NkOP0tL3fK8fEG1+2/iWnbExqdhcL8v4Z WsZfcHy1LsPLQqbIgn6zpyjVeIgrF35PrKKXWSKaX/f0u1biH//u3P12298i8Ndyj2 Fx4Cb92aOLQLARTjWru4CbMzoJb1ULBFd9StJbGHx4djUvXF8NA8T38Jeg39VFFq/l fNdMDWKjsyLCmtuNU7W241XpbV491BtDm4BXiRvT5PQ0g3RZZlP94PRwahRcsS0qR3 6Q+/eEUIGPYmS4e2JeUtH1cBKKg90JHwVuJXpUmMoaLwGscosAhw3cPLK24PamzBYC yCyQzUpDBRyFhrVOmd0lpeRN6SY2lW7a2vkTSBlb7j3Rr5PWMZ7VgO6RYlSNhluxEv GFfz+oVmaxQE2pYpRNo5rV5Vn1ZUZoWvsRh6ChyVitGgZauaWIBRKSI3sGv2e8bEaR m3XW4Gj329NhuzVI7hMtEmPg= X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on wolfsden X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id CF550342A88; Sun, 12 Jan 2025 23:03:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1736723003; bh=cGFxvdC/c6T4ddXl9L2OjLona+t5z0KhM0b5+IkJrd4=; h=From:To:Cc:Subject:Date; b=Bd5U8sbKPSGVRMegt6FIy9+/ty7Wdx060FX6ynMb7wzd7HTIST+UtdtfrwkcTpG/+ swpoNmKj9XAvU+iOiTBK8wPwggvSZsQAy1Y1vUpOcG2zIUtFH/RsgWCITRCpxI1bF8 wnNhcfiwpGjLbJtozdAWTmZsY9zcrEQP5+LKnfJsHALd3G1rsT/wmG0Fd1BMHSCPU8 h4Lp/Amb1pqXdKk1vw8StBI/410eCqMDz4t8cFkIzR1NX9aRFmE2bCvwDM6UP8zPOk 8byTK9yxQY8ehIkX92kM87tVGsSsna15n4EfUdlgmKEdAeakE/JJT986foTSNUFCG1 m4ZqJjufsg7hlYjmpE94XNAGcz+Fw42mtmAjhHRCe8Ba0akRZhuOUoMAHimynXKnny kRyr8vjGsohGBsTHjHNf1erjdKdj3r1FExDCQW2SOMhlczxHQX9O1UDaZCUPUa3MBW C44vrM2Yxp0qY6+IegT9O4EJREqBbyHE2Lag4UGP9hm8OVQImNJ6ydWscRagfx7l6r 3IikeNE+qGK8H03nYokf5frjYv/BzJiAH7LW5c+ohKtaZ7gVgfb9fU1XptK88iVKuz JVO8+lQzVl3OgY3mLwCBPlx2t073GQGCM6xRhvRyetnqI+kfy8LTkaUlXGa0AZR/V8 Oya3/9KAcP4ejHnIyxCUbHDc= From: Tomas Volf <~@wolfsden.cz> Date: Mon, 13 Jan 2025 00:03:16 +0100 Message-ID: <cover.1736722765.git.~@wolfsden.cz> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=37.205.8.62; envelope-from=~@wolfsden.cz; helo=wolfsden.cz X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) For machines running with an uninterruptible power supply (UPS), it is necessary to be able to react to events from it. That allows to, for example, safely shutdown the system when battery is getting low or get a notification that battery needs to be replaced. This series adds package and service type for apcupsd, daemon to manage UPS devices made by American Power Conversion Corporation (APC). Tomas Volf (2): gnu: Add apcupsd. services: Add power. doc/guix.texi | 374 +++++++++++++++++++++- gnu/local.mk | 2 + gnu/packages/power.scm | 125 ++++++++ gnu/services/power.scm | 690 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1188 insertions(+), 3 deletions(-) create mode 100644 gnu/packages/power.scm create mode 100644 gnu/services/power.scm -- 2.47.1
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Tomas Volf <~@wolfsden.cz> Subject: bug#75528: Acknowledgement ([PATCH 0/2] Add apcupsd) Message-ID: <handler.75528.B.173672302126859.ack <at> debbugs.gnu.org> References: <cover.1736722765.git.~@wolfsden.cz> X-Gnu-PR-Message: ack 75528 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 75528 <at> debbugs.gnu.org Date: Sun, 12 Jan 2025 23:04:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. As you requested using X-Debbugs-CC, your message was also forwarded to Ludovic Court=C3=A8s <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@gma= il.com> (after having been given a bug report number, if it did not have one). Your message has been sent to the package maintainer(s): guix-patches@HIDDEN If you wish to submit further information on this problem, please send it to 75528 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 75528: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D75528 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: [bug#75528] [PATCH 1/2] gnu: Add apcupsd. Resent-From: Tomas Volf <~@wolfsden.cz> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Sun, 12 Jan 2025 23:06:01 +0000 Resent-Message-ID: <handler.75528.B75528.173672313227428 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 75528 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75528 <at> debbugs.gnu.org Cc: Tomas Volf <~@wolfsden.cz> Received: via spool by 75528-submit <at> debbugs.gnu.org id=B75528.173672313227428 (code B ref 75528); Sun, 12 Jan 2025 23:06:01 +0000 Received: (at 75528) by debbugs.gnu.org; 12 Jan 2025 23:05:32 +0000 Received: from localhost ([127.0.0.1]:49448 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tX71P-00078J-K4 for submit <at> debbugs.gnu.org; Sun, 12 Jan 2025 18:05:32 -0500 Received: from wolfsden.cz ([37.205.8.62]:59848) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1tX71M-000788-7L for 75528 <at> debbugs.gnu.org; Sun, 12 Jan 2025 18:05:29 -0500 Received: by wolfsden.cz (Postfix, from userid 104) id D6036342C1D; Sun, 12 Jan 2025 23:05:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1736723126; bh=p0bKALsrwxfPOLQkolSwo4qZhiRU8Etm+n76/Meke8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RP/2ORxPaEdcQtl5WsjLev/9oB93Wj+tosAyE3GrT7P+DAW0JU8VafZrtTQVf1ek3 yIohgWmHB30Whu/ktIMLV4D8zBevNCgTGOt2FWPiowzmLkDDem7b39srggfm8bCSyX XLeCZs0Yc9Oy+kbALrfTuNXUeVuujz0+f5G9UjUwgLDLOk9UcHf4CYV/kJDQ3t8L1P EfG0AbuewzQXzxTqSVNjW555nFt1hPxnG6lZnAc0A+HJvmXw5VwZFOA9EtNMyQCtT+ fFyYbMv3fc6BBC0wjGD6pJNPOGyaGSxO1TE6wQduGCeo8Ss5HyZK4WW27K+onmC25a +XFcFeRMAZIOu/f23ySxsqzWFNP8lSJdYVGLbE1O4bq0Arn5zm7KHGbQ/dVAVYrfg9 2YebP1qHQ6ie+AWORu2t7oMPbDgdVUtwz9HXGBqZ0HRe9odWV423E3P8yD2KF4MQq4 mmVo4jX1r2V4ywK5kQ3LmGQQPQTSTBGeVrsUq0Mfo51jiSJe7ocbo6uuWHgYeuRKEI scKnPbbvWubV6jk1U8FPdQuic+5fOQrJl6q/dcgR99OCMC9yloNaCeMvjTGs4aUYF7 AKHH5m18LUT8M0TaC22nU6Wj9ODDG+fK2AB16iBFDBA1fno1VBQ0rMN1SmBReCSvC5 Dslcb/ucoesb1Ui3ez3RLxns= X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on wolfsden X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id F2D12341673; Sun, 12 Jan 2025 23:05:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1736723126; bh=p0bKALsrwxfPOLQkolSwo4qZhiRU8Etm+n76/Meke8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RP/2ORxPaEdcQtl5WsjLev/9oB93Wj+tosAyE3GrT7P+DAW0JU8VafZrtTQVf1ek3 yIohgWmHB30Whu/ktIMLV4D8zBevNCgTGOt2FWPiowzmLkDDem7b39srggfm8bCSyX XLeCZs0Yc9Oy+kbALrfTuNXUeVuujz0+f5G9UjUwgLDLOk9UcHf4CYV/kJDQ3t8L1P EfG0AbuewzQXzxTqSVNjW555nFt1hPxnG6lZnAc0A+HJvmXw5VwZFOA9EtNMyQCtT+ fFyYbMv3fc6BBC0wjGD6pJNPOGyaGSxO1TE6wQduGCeo8Ss5HyZK4WW27K+onmC25a +XFcFeRMAZIOu/f23ySxsqzWFNP8lSJdYVGLbE1O4bq0Arn5zm7KHGbQ/dVAVYrfg9 2YebP1qHQ6ie+AWORu2t7oMPbDgdVUtwz9HXGBqZ0HRe9odWV423E3P8yD2KF4MQq4 mmVo4jX1r2V4ywK5kQ3LmGQQPQTSTBGeVrsUq0Mfo51jiSJe7ocbo6uuWHgYeuRKEI scKnPbbvWubV6jk1U8FPdQuic+5fOQrJl6q/dcgR99OCMC9yloNaCeMvjTGs4aUYF7 AKHH5m18LUT8M0TaC22nU6Wj9ODDG+fK2AB16iBFDBA1fno1VBQ0rMN1SmBReCSvC5 Dslcb/ucoesb1Ui3ez3RLxns= From: Tomas Volf <~@wolfsden.cz> Date: Mon, 13 Jan 2025 00:05:13 +0100 Message-ID: <51cba7679af5c4aa9cf0e6d70453e369ff0909d6.1736722765.git.~@wolfsden.cz> X-Mailer: git-send-email 2.47.1 In-Reply-To: <cover.1736722765.git.~@wolfsden.cz> References: <cover.1736722765.git.~@wolfsden.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) * gnu/packages/power.scm (apcupsd): New variable. Change-Id: I74f59cd1fa2a13954117ff1683a10a84576cc839 --- gnu/local.mk | 1 + gnu/packages/power.scm | 125 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 gnu/packages/power.scm diff --git a/gnu/local.mk b/gnu/local.mk index 855f2acccc..6ca7bf68ac 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -557,6 +557,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/polkit.scm \ %D%/packages/popt.scm \ %D%/packages/potassco.scm \ + %D%/packages/power.scm \ %D%/packages/printers.scm \ %D%/packages/profiling.scm \ %D%/packages/prolog.scm \ diff --git a/gnu/packages/power.scm b/gnu/packages/power.scm new file mode 100644 index 0000000000..98dc98c6e4 --- /dev/null +++ b/gnu/packages/power.scm @@ -0,0 +1,125 @@ +;;; Copyright (C) 2025 Tomas Volf <~@wolfsden.cz> +;;; Copyright (C) 2023 Raven Hallsby <karl@HIDDEN> + +;;;; Commentary: + +;;; Power-related packages. + +;;;; Code: + +(define-module (gnu packages power) + #:use-module (gnu) + #:use-module (gnu packages libusb) + #:use-module (gnu packages linux) + #:use-module (gnu packages pkg-config) + #:use-module (gnu packages python-xyz) + #:use-module (guix build-system gnu) + #:use-module (guix download) + #:use-module (guix gexp) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages)) + +(define-public apcupsd + (package + (name "apcupsd") + (version "3.14.14") + (source (origin + (method url-fetch) + (uri + (string-append + "mirror://sourceforge/" name "/" name " - Stable/" version + "/" name "-" version ".tar.gz")) + (sha256 + (base32 + "0rwqiyzlg9p0szf3x6q1ppvrw6f6dbpn2rc5z623fk3bkdalhxyv")))) + (native-inputs + (list pkg-config python-docutils)) + (inputs + (list libusb libusb-compat)) + (outputs '("out" "doc")) + (build-system gnu-build-system) + (arguments + (list + #:configure-flags + #~(list + ;; The configure script ignores --prefix for most of the paths. + (string-append "--exec-prefix=" #$output) + (string-append "--mandir=" #$output "/share/man") + (string-append "--sbindir=" #$output "/sbin") + (string-append "--sysconfdir=" #$output "/etc/apcupsd") + (string-append "--with-halpolicydir=" #$output "/share/halpolicy") + + ;; Put us into the version string. + "--with-distname=GNU/Guix" + "--disable-install-distdir" + + ;; State directories. + "--localstatedir=/var" + "--with-log-dir=/var/log" + "--with-pid-dir=/var/run" + "--with-lock-dir=/var/run/apcupsd/lock" + "--with-nologin=/var/run/apcupsd" + "--with-pwrfail-dir=/var/run/apcupsd" + + ;; Configure requires these, but we do not use the genenerated + ;; apcupsd.conf, so in order to reduce dependencies of the package, + ;; provide fake values. + (string-append "ac_cv_path_SHUTDOWN=/nope") + (string-append "ac_cv_path_APCUPSD_MAIL=/nope") + ;; While `wall' is not expanded anywhere, it still is searched for. + (string-append "ac_cv_path_WALL=/nope") + + ;; Enable additional drivers. + "--enable-test" + "--enable-usb" + "--enable-modbus-usb") + #:tests? #f ; There are no tests. + #:modules (cons '(ice-9 ftw) %default-gnu-modules) + #:phases + #~(modify-phases %standard-phases + ;; These are not installed, so trick Make into thinking they were + ;; already generated. Allows us not to depend on mandoc, util-linux. + (add-before 'configure 'touch-txt-docs + (lambda _ + (for-each (lambda (f) + (call-with-output-file f close-port)) + '("doc/apcupsd.man.txt" + "doc/apcaccess.man.txt" + "doc/apctest.man.txt" + "doc/apccontrol.man.txt" + "doc/apcupsd.conf.man.txt")))) + (add-after 'build 'build-manual + (lambda _ + (invoke "make" "-C" "doc/manual" "manual.html"))) + (add-after 'install-license-files 'move-doc + (lambda _ + (let ((target (string-append #$output:doc + "/share/doc/" + (strip-store-file-name #$output)))) + (mkdir-p target) + (for-each (lambda (f) + (copy-file (string-append "doc/manual/" f) + (string-append target "/" f))) + (scandir "doc/manual" + (lambda (f) + (or (string-suffix? ".png" f) + (string-suffix? ".html" f)))))))) + ;; If sending mails is required, use proper mail program. + (add-after 'install 'remove-smtp + (lambda _ + (delete-file (string-append #$output "/sbin/smtp")))) + ;; The configuration files and scripts are not really suitable for + ;; Guix, and our service provides its own version anyway. So nuke + ;; these to make sure `apcupsd' and `apctest' executed without any + ;; arguments fail. `apctest' actually segfaults, but only after + ;; printing an error ¯\_(ツ)_/¯. + (add-after 'install 'remove-etc-apcupsd + (lambda _ + (delete-file-recursively (string-append #$output "/etc/apcupsd"))))))) + (home-page "https://www.apcupsd.org") + (synopsis "A daemon for controlling APC UPSes") + (description "Apcupsd can be used for power mangement and controlling most +of APC’s UPS models on Unix and Windows machines. Apcupsd works with most of +APC’s Smart-UPS models as well as most simple signalling models such a Back-UPS, +and BackUPS-Office.") + (license license:gpl2))) -- 2.47.1
X-Loop: help-debbugs@HIDDEN Subject: [bug#75528] [PATCH 2/2] services: Add power. Resent-From: Tomas Volf <~@wolfsden.cz> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: ludo@HIDDEN, maxim.cournoyer@HIDDEN, guix-patches@HIDDEN Resent-Date: Sun, 12 Jan 2025 23:06:02 +0000 Resent-Message-ID: <handler.75528.B75528.173672313827448 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 75528 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75528 <at> debbugs.gnu.org Cc: Tomas Volf <~@wolfsden.cz>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN> X-Debbugs-Original-Xcc: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN> Received: via spool by 75528-submit <at> debbugs.gnu.org id=B75528.173672313827448 (code B ref 75528); Sun, 12 Jan 2025 23:06:02 +0000 Received: (at 75528) by debbugs.gnu.org; 12 Jan 2025 23:05:38 +0000 Received: from localhost ([127.0.0.1]:49450 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tX71U-00078c-I1 for submit <at> debbugs.gnu.org; Sun, 12 Jan 2025 18:05:38 -0500 Received: from wolfsden.cz ([37.205.8.62]:59852) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1tX71O-00078H-Rw for 75528 <at> debbugs.gnu.org; Sun, 12 Jan 2025 18:05:33 -0500 Received: by wolfsden.cz (Postfix, from userid 104) id E84613414EE; Sun, 12 Jan 2025 23:05:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1736723129; bh=IQ6imuI/xWTpcFS3o6s/qnP05FzScxSeK9RdNZROh6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pDlUZUvuZegoTTAZ6YjcpkxqSZqLHyk/sHRq8HcVAb/acjQpRO7lyRWDMwI5y3fl9 QddCyzx3ohlrGF903NNDrhhMjpFTavsLzCZVrfI+tMlSNfL1cvZEmn3gE9BNM8SJU6 wAunANTteV/DNk65Af8gq8pr/HNI8k9FfYDPzxkocYulHiGiP+DgVvXse5ilZTexw7 f+DZ/b3WzPyABk4o4MA2do6bp2ljm/dtABkGQT43jm82f3Rk47yu+ZREflbP4A7XCo eJpSJUnfRzJ8Fj2sOXFkQbEuMVLhNLRNFs2XRaxpxAifjzFAhmHKvsRunlYGyNAP9x gQ5DLqzNokePWy9Ls7y/Y9/1SvO9hVRgu7jiKgYyWuL1dLV1Qjt7UXx6KpQUr37p39 PCYcA/SD52pTZoaW2W2WY+kwymOgUo0fKOg59iUyaNu+yXrjxtWI3cTrdg9U1VsTh3 MCmZz0ns7MUgGdwgwygzEqK+h5sNKV0cij2Ufel4NbDsPaqcpLGi+icszEEPDAC0pS xdIdWqahkJF0T/hwE0lC4cxO6g4v+7MS/brPaz5/2mGlNBesZt5U5kCxQY7qax29cX bWC3b9E9Sjwxuu7Cn8dkuNYlv2DNm4Z6Kg3sSWvCgzUYzDDGkFHkvvxZF7hjFtp60P 62a3ntdrD04aabBgG9t2XH2k= X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on wolfsden X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id 7FD0C34242F; Sun, 12 Jan 2025 23:05:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1736723126; bh=IQ6imuI/xWTpcFS3o6s/qnP05FzScxSeK9RdNZROh6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=klbBR33rxP30rS96Q4MDlPmpUYu4ZtuO9NdLzyOX7obfmR32F0uZUup/Jp161KjzT 2lEpBrKdTdgpw8YdVSnvUtVpKlFjjzQa3MbNDpWCLiAUVYL/fasKxOSKJWxGMl0tCi a9/V66YL4Hh+2Y4UCvH8xSBCZ+YKmORrZDOSrVLrOUZcuKU0JiQY4oTOhbRyYrNYt1 YIF0AxKtQZN9ezGzi6TpIflAbJluUnSxg/uLB1A8yrSbPXb7svqXGEtJ82udEwL8Xx v19li8YLWoizPaSvKIFUFQtS89RQ3HQ2G8tFJM2cXoR9GvKHOcAhaQnIDE4PYSl2dC Oik2TOdu+i6plLXTzthgFe7gghkSlUhNEuiSoZe5Gco6lzGXgyQXxr5Cay+MN0OLg6 iHS9IBkcbb6Epnc45cXHEdid+Ivf8HfgUxzg/A3GtuYb/3d33zJNyVf0/Uk+8bBjWF juDosGjRNKDxCbH/kLAt/myDFHhXztLuiTzcZDIlMK660+j/MU1crjCnBJH7sxk5O9 dAY6/zkTRErorxoJ8rPx9g7Zi0O1Qbubo79FEBgIZq3xi95iyX0sUlrVj3ISnHeDWv RYB8LjtcVUxPwGebTT0zlP7e6+4qeiS79WBKNM4LiyrbcyH7EnoV0pJszUF3tskjff Cb7Q8548JouLQdfD4yamMics= From: Tomas Volf <~@wolfsden.cz> Date: Mon, 13 Jan 2025 00:05:14 +0100 Message-ID: <05ba17f2babc772a26072dca72c2e6e6f852e0ad.1736722765.git.~@wolfsden.cz> X-Mailer: git-send-email 2.47.1 In-Reply-To: <cover.1736722765.git.~@wolfsden.cz> References: <cover.1736722765.git.~@wolfsden.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) * gnu/services/power.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * doc/guix.texi (Power Management Services): Document service and data types. Change-Id: If205d19bea1d20a99309626e28521a2d6fe6702f --- doc/guix.texi | 374 +++++++++++++++++++++- gnu/local.mk | 1 + gnu/services/power.scm | 690 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1062 insertions(+), 3 deletions(-) create mode 100644 gnu/services/power.scm diff --git a/doc/guix.texi b/doc/guix.texi index d6e17c74cd..6cb11200cd 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -123,7 +123,7 @@ Copyright @copyright{} 2023 Thomas Ieong@* Copyright @copyright{} 2023 Saku Laesvuori@* Copyright @copyright{} 2023 Graham James Addis@* -Copyright @copyright{} 2023, 2024 Tomas Volf@* +Copyright @copyright{} 2023-2025 Tomas Volf@* Copyright @copyright{} 2024 Herman Rimm@* Copyright @copyright{} 2024 Matthew Trzcinski@* Copyright @copyright{} 2024 Richard Sent@* @@ -420,7 +420,7 @@ Top * Network File System:: NFS related services. * Samba Services:: Samba services. * Continuous Integration:: Cuirass and Laminar services. -* Power Management Services:: Extending battery life. +* Power Management Services:: Extending battery life, etc. * Audio Services:: The MPD. * Virtualization Services:: Virtualization services. * Version Control Services:: Providing remote access to Git repositories. @@ -19255,7 +19255,7 @@ Services * Network File System:: NFS related services. * Samba Services:: Samba services. * Continuous Integration:: Cuirass and Laminar services. -* Power Management Services:: Extending battery life. +* Power Management Services:: Extending battery life, etc. * Audio Services:: The MPD. * Virtualization Services:: Virtualization services. * Version Control Services:: Providing remote access to Git repositories. @@ -36263,6 +36263,374 @@ Power Management Services @end table @end deftp +The @code{(gnu services power)} module provides a service definition for +@uref{http://www.apcupsd.org/, apcupsd}, a utility to interact with APC +UPSes. Apcupsd also works with some OEM-branded products manufactured +by APC. + +@defvar apcupsd-service-type +The service type for apcupsd. For USB UPSes no configuration is +necessary, however tweaking some fields to better suit your needs might +be desirable. The defaults are taken from the upstream configuration +and they are not very conservative (@code{battery-level} of 5% is too +low in my opinion). + +The default event handlers do send emails, read more in +@ref{apcupsd-event-handlers}. + +@lisp +(service apcupsd-service-type) +@end lisp +@end defvar + +@deftp {Data Type} apcupsd-configuration + +Available @code{apcupsd-configuration} fields are: + +@table @asis +@item @code{package} (default: @code{apcupsd}) (type: package) +Package to use. + +@item @code{shepherd-base-name} (default: @code{apcupsd}) (type: symbol) +Base name of the shepherd service. You can add the service multiple +times with different prefix to manage multiple UPSes. + +@item @code{auto-start?} (default: @code{#t}) (type: boolean) +Should the shepherd service auto-start? + +@item @code{pid-file} (default: @code{"/var/run/apcupsd.pid"}) (type: string) +Path to the pid file. + +@item @code{debug-level} (default: @code{0}) (type: integer) +Logging verbosity. Bigger number means more logs. In the source code I +saw up to @code{300}, so for all logs, @code{999} seems reasonable. + +@item @code{run-dir} (default: @code{"/var/run/apcupsd"}) (type: string) +Directory containing runtime information. You need to change this if +you desire to run multiple instances of the daemon. + +@item @code{name} (type: maybe-string) +Use this to give your UPS a name in log files and such. This is +particularly useful if you have multiple UPSes. This does not set the +EEPROM. It should be 8 characters or less. + +@item @code{cable} (default: @code{usb}) (type: enum-cable) +The type of cable connecting the UPS to your computer. Possible generic +choices are @code{'simple}, @code{'smart}, @code{'ether} and +@code{'usb}. Or a specific cable model number may be used: +@code{'940-0119A}, @code{'940-0127A}, @code{'940-0128A}, +@code{'940-0020B}, @code{'940-0020C}, @code{'940-0023A}, +@code{'940-0024B}, @code{'940-0024C}, @code{'940-1524C}, +@code{'940-0024G}, @code{'940-0095A}, @code{'940-0095B}, +@code{'940-0095C}, @code{'940-0625A}, @code{'M-04-02-2000}. + +@item @code{type} (default: @code{usb}) (type: enum-type) +Type of the UPS you have. + +@table @code +@item apcsmart +Newer serial character device, appropriate for SmartUPS models using a +serial cable (not USB). + +@item usb +Most new UPSes are USB. + +@item net +Network link to a master apcupsd through apcupsd's Network Information +Server. This is used if the UPS powering your computer is connected to +a different computer for monitoring. + +@item snmp +SNMP network link to an SNMP-enabled UPS device. + +@item netsnmp +Same as SNMP above but requires use of the net-snmp library. Unless you +have a specific need for this old driver, you should use @code{'snmp} +instead. + +@item dumb +Old serial character device for use with simple-signaling UPSes. + +@item pcnet +PowerChute Network Shutdown protocol which can be used as an alternative +to SNMP with the AP9617 family of smart slot cards. + +@item modbus +Serial device for use with newest SmartUPS models supporting the MODBUS +protocol. + +@end table + +@item @code{device} (default: @code{""}) (type: string) +For USB UPSes, usually you want to set this to an empty string (the +default). For other UPS types, you must specify an appropriate port or +address. + +@table @code +@item apcsmart +Set to the appropriate @file{/dev/tty**} device. + +@item usb +A null string setting enables autodetection, which is the best choice +for most installations. + +@item net +Set to @code{@var{hostname}:@var{port}}. + +@item snmp +Set to @code{@var{hostname}:@var{port}:@var{vendor}:@var{community}}. +@var{hostname} is the ip address or hostname of the UPS on the network. +@var{vendor} can be can be "APC" or "APC_NOTRAP". "APC_NOTRAP" will +disable SNMP trap catching; you usually want "APC". @var{port} is +usually 161. @var{community} is usually "private". + +@item netsnmp +Same as @code{'snmp}. + +@item dumb +Set to the appropriate @file{/dev/tty**} device. + +@item pcnet +Set to @code{@var{ipaddr}:@var{username}:@var{passphrase}:@var{port}}. +@var{ipaddr} is the IP address of the UPS management card. +@var{username} and @var{passphrase} are the credentials for which the +card has been configured. @var{port} is the port number on which to +listen for messages from the UPS, normally 3052. If this parameter is +empty or missing, the default of 3052 will be used. + +@item modbus +Set to the appropriate @file{/dev/tty**} device. You can also leave it +empty for MODBUS over USB or set to the serial number of the UPS. + +@end table + +@item @code{poll-time} (default: @code{60}) (type: integer) +Interval (in seconds) at which apcupsd polls the UPS for status. This +setting applies both to directly-attached UPSes (apcsmart, usb, dumb) +and networked UPSes (net, snmp). Lowering this setting will improve +apcupsd's responsiveness to certain events at the cost of higher CPU +utilization. + +@item @code{on-batery-delay} (default: @code{6}) (type: integer) +The the time in seconds from when a power failure is detected until we +react to it with an onbattery event. The @code{'powerout} event will be +triggered immediately when a power failure is detected. However, the +@code{'onbattery} event will be trigger only after this delay. + +@item @code{battery-level} (default: @code{5}) (type: integer) +If during a power failure, the remaining battery percentage (as reported +by the UPS) is below or equal to this value, apcupsd will initiate a +system shutdown. + +@quotation Note +@code{battery-level}, @code{remaining-minutes}, and @code{timeout} work +in conjunction, so the first that occurs will cause the initation of a +shutdown. +@end quotation + +@item @code{remaining-minutes} (default: @code{3}) (type: integer) +If during a power failure, the remaining runtime in minutes (as +calculated internally by the UPS) is below or equal to this value, +apcupsd will initiate a system shutdown. + +@quotation Note +@code{battery-level}, @code{remaining-minutes}, and @code{timeout} work +in conjunction, so the first that occurs will cause the initation of a +shutdown. +@end quotation + +@item @code{timeout} (default: @code{0}) (type: integer) +If during a power failure, the UPS has run on batteries for this many +seconds or longer, apcupsd will initiate a system shutdown. A value of +0 disables this timer. + +@quotation Note +@code{battery-level}, @code{remaining-minutes}, and @code{timeout} work +in conjunction, so the first that occurs will cause the initation of a +shutdown. +@end quotation + +@item @code{annoy-interval} (default: @code{300}) (type: integer) +Time in seconds between annoying users (via the @code{'annoyme} event) +to sign off prior to system shutdown. 0 disables. + +@item @code{annoy-delay} (default: @code{60}) (type: integer) +Initial delay in seconds after power failure before warning users to get +off the system. + +@item @code{no-logon} (default: @code{disable}) (type: enum-no-logon) +The condition which determines when users are prevented from logging in +during a power failure. + +@item @code{kill-delay} (default: @code{0}) (type: integer) +If this is non-zero, apcupsd will continue running after a shutdown has +been requested, and after the specified time in seconds attempt to kill +the power. This is for use on systems where apcupsd cannot regain +control after a shutdown. + +@item @code{net-server} (default: @code{#f}) (type: boolean) +If enabled, a network information server process will be started. + +@item @code{net-server-ip} (default: @code{"127.0.0.1"}) (type: string) +IP address on which NIS server will listen for incoming connections. + +@item @code{net-server-port} (default: @code{3551}) (type: integer) +IP port on which NIS server will listen for incoming connections. + +@item @code{net-server-events-file} (type: maybe-string) +If you want the last few EVENTS to be available over the network by the +network information server, you must set this to a file patch. + +@item @code{net-server-events-file-max-size} (default: @code{10}) (type: integer) +Maximum size of the events file in kilobytes. + +@item @code{class} (default: @code{standalone}) (type: enum-class) +Normally standalone unless you share an UPS using an APC ShareUPS card. + +@item @code{mode} (default: @code{disable}) (type: enum-mode) +Normally disable unless you share an UPS using an APC ShareUPS card. + +@item @code{stat-time} (default: @code{0}) (type: integer) +Time interval in seconds between writing the status file, 0 disables. + +@item @code{log-stats} (default: @code{#f}) (type: boolean) +Also write the stats as a logs. This generates a lot of output. + +@item @code{data-time} (default: @code{0}) (type: integer) +Time interval in seconds between writing the data records to the log +file, 0 disables. + +@item @code{facility} (type: maybe-string) +The logging facility for the syslog. + +@item @code{event-handlers} (type: apcupsd-event-handlers) +Handlers for events produced by apcupsd. + +@end table + +@end deftp + +@anchor{apcupsd-event-handlers} +@deftp {Data Type} apcupsd-event-handlers + +For description of the events please refer to the @command{apcupsd}'s +manual, which can be found in the @samp{apcupsd-doc} package. + +Each handler shall be a gexp. It is spliced into the control script for +the daemon. In addition to the standard Guile programming environment, +these procedures and variables are also available. + +@table @code +@item conf +Variable containing path to the configuration file. + +@item powerfail-file +Variable containing path to the powerfail file. + +@item cmd +The event currently being handled. + +@item name +The name of the UPS as specified in the configuration file. + +@item connected +Is @code{"1"} if apcupsd is connected to the UPS via a serial port (or a +USB port). In most configurations, this will be the case. In the case +of a Slave machine where apcupsd is not directly connected to the UPS, +this value will be @code{"0"}. + +@item powered +Is @code{"1"} if the computer on which @command{apcupsd} is running is +powered by the UPS and @code{"0"} if not. At the moment, this value is +unimplemented and always @code{"0"}. + +@item (err @var{fmt} @var{args...}) +Wrapper around @code{format} outputting to @code{(current-error-port)}. + +@item (wall @var{fmt} @var{args...}) +Wrapper around @code{format} outputting via @command{wall}. + +@item (apcupsd @var{args...}) +Call @command{apcupsd} while passing the correct configuration file and +all the arguments. + +@item (mail-to-root @var{subject} @var{body}) +Send an email to the local administrator. This procedure assumes the +@command{sendmail} is located at @command{/run/privileged/bin/sendmail} +(as would be the case with @code{opensmtpd-service-type}). + +@end table + +Available @code{apcupsd-event-handlers} fields are: + +@table @asis +@item @code{killpower} (type: gexp) +Handler for killpower event. + +@item @code{commfailure} (type: gexp) +Handler for commfailure event. + +@item @code{commok} (type: gexp) +Handler for commfailure event. + +@item @code{powerout} (type: gexp) +Handler for powerout event. + +@item @code{onbattery} (type: gexp) +Handler for onbattery event. + +@item @code{offbattery} (type: gexp) +Handler for offbattery event. + +@item @code{mainsback} (type: gexp) +Handler for mainsback event. + +@item @code{failing} (type: gexp) +Handler for failing event. + +@item @code{timeout} (type: gexp) +Handler for timeout event. + +@item @code{loadlimit} (type: gexp) +Handler for loadlimit event. + +@item @code{runlimit} (type: gexp) +Handler for runlimit event. + +@item @code{doreboot} (type: gexp) +Handler for doreboot event. + +@item @code{doshutdown} (type: gexp) +Handler for doshutdown event. + +@item @code{annoyme} (type: gexp) +Handler for annoyme event. + +@item @code{emergency} (type: gexp) +Handler for emergency event. + +@item @code{changeme} (type: gexp) +Handler for changeme event. + +@item @code{remotedown} (type: gexp) +Handler for remotedown event. + +@item @code{startselftest} (type: gexp) +Handler for startselftest event. + +@item @code{endselftest} (type: gexp) +Handler for endselftest event. + +@item @code{battdetach} (type: gexp) +Handler for battdetach event. + +@item @code{battattach} (type: gexp) +Handler for battattach event. + +@end table + +@end deftp + @node Audio Services @subsection Audio Services diff --git a/gnu/local.mk b/gnu/local.mk index 6ca7bf68ac..dea0e43fe6 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -758,6 +758,7 @@ GNU_SYSTEM_MODULES = \ %D%/services/nix.scm \ %D%/services/nfs.scm \ %D%/services/pam-mount.scm \ + %D%/services/power.scm \ %D%/services/science.scm \ %D%/services/security.scm \ %D%/services/security-token.scm \ diff --git a/gnu/services/power.scm b/gnu/services/power.scm new file mode 100644 index 0000000000..a6f9259eb3 --- /dev/null +++ b/gnu/services/power.scm @@ -0,0 +1,690 @@ +;;; Copyright (C) 2025 Tomas Volf <~@wolfsden.cz> + +;;;; Commentary: + +;;; Power-related services. + +;;;; Code: + +(define-module (gnu services power) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (ice-9 match) + #:use-module (gnu) + #:use-module (gnu packages admin) + #:use-module (gnu packages linux) + #:use-module (gnu packages power) + #:use-module (gnu services) + #:use-module (gnu services configuration) + #:use-module (gnu services shepherd) + #:use-module (guix packages) + #:use-module (guix records) + #:export (apcupsd-service-type + + apcupsd-configuration + apcupsd-configuration-package + apcupsd-configuration-shepherd-base-name + apcupsd-configuration-auto-start? + apcupsd-configuration-pid-file + apcupsd-configuration-debug-level + apcupsd-configuration-run-dir + apcupsd-configuration-name + apcupsd-configuration-cable + apcupsd-configuration-type + apcupsd-configuration-device + apcupsd-configuration-poll-time + apcupsd-configuration-on-batery-delay + apcupsd-configuration-battery-level + apcupsd-configuration-remaining-minutes + apcupsd-configuration-timeout + apcupsd-configuration-annoy-interval + apcupsd-configuration-annoy-delay + apcupsd-configuration-no-logon + apcupsd-configuration-kill-delay + apcupsd-configuration-net-server + apcupsd-configuration-net-server-ip + apcupsd-configuration-net-server-port + apcupsd-configuration-net-server-events-file + apcupsd-configuration-net-server-events-file-max-size + apcupsd-configuration-class + apcupsd-configuration-mode + apcupsd-configuration-stat-time + apcupsd-configuration-log-stats + apcupsd-configuration-data-time + apcupsd-configuration-facility + apcupsd-configuration-event-handlers + + apcupsd-event-handlers-annoyme + apcupsd-event-handlers-battattach + apcupsd-event-handlers-battdetach + apcupsd-event-handlers-changeme + apcupsd-event-handlers-commfailure + apcupsd-event-handlers-commok + apcupsd-event-handlers-doreboot + apcupsd-event-handlers-doshutdown + apcupsd-event-handlers-emergency + apcupsd-event-handlers-endselftest + apcupsd-event-handlers-failing + apcupsd-event-handlers-killpower + apcupsd-event-handlers-loadlimit + apcupsd-event-handlers-mainsback + apcupsd-event-handlers-offbattery + apcupsd-event-handlers-onbattery + apcupsd-event-handlers-powerout + apcupsd-event-handlers-remotedown + apcupsd-event-handlers-runlimit + apcupsd-event-handlers-startselftest + apcupsd-event-handlers-timeout)) + +(define-configuration/no-serialization apcupsd-event-handlers + (killpower + (gexp + #~((wall "Apccontrol doing: apcupsd --killpower on UPS ~a" name) + (sleep 10) + (apcupsd "--killpower") + (wall "Apccontrol has done: apcupsd --killpower on UPS ~a" name))) + "Handler for killpower event.") + (commfailure + (gexp + #~((let ((msg (format #f "~a Communications with UPS ~a lost." + (gethostname) name))) + (mail-to-root msg msg)) + (wall "Warning: communications lost with UPS ~a" name))) + "Handler for commfailure event.") + (commok + (gexp + #~((let ((msg (format #f "~a Communications with UPS ~a restored." + (gethostname) name))) + (mail-to-root msg msg)) + (wall "Communications restored with UPS ~a" name))) + "Handler for commfailure event.") + (powerout + (gexp + #~(#t)) + "Handler for powerout event.") + (onbattery + (gexp + #~((let ((msg (format #f "~a UPS ~a Power Failure !!!" + (gethostname) name))) + (mail-to-root msg msg)) + (wall "Power failure on UPS ~a. Running on batteries." name))) + "Handler for onbattery event.") + (offbattery + (gexp + #~((let ((msg (format #f "~a UPS ~a Power has returned." + (gethostname) name))) + (mail-to-root msg msg)) + (wall "Power has returned on UPS ~a..." name))) + "Handler for offbattery event.") + (mainsback + (gexp + #~((when (file-exists? powerfail-file) + (wall "Continuing with shutdown.")))) + "Handler for mainsback event.") + (failing + (gexp + #~((wall "Battery power exhausted on UPS ~a. Doing shutdown." name))) + "Handler for failing event.") + (timeout + (gexp + #~((wall "Battery time limit exceeded on UPS ~a. Doing shutdown." name))) + "Handler for timeout event.") + (loadlimit + (gexp + #~((wall "Remaining battery charge below limit on UPS ~a. Doing shutdown." name))) + "Handler for loadlimit event.") + (runlimit + (gexp + #~((wall "Remaining battery runtime below limit on UPS ~a. Doing shutdown." name))) + "Handler for runlimit event.") + (doreboot + (gexp + #~((wall "UPS ~a initiating Reboot Sequence" name) + (system* #$(file-append shepherd "/sbin/reboot")))) + "Handler for doreboot event.") + (doshutdown + (gexp + #~((wall "UPS ~a initiated Shutdown Sequence" name) + (system* #$(file-append shepherd "/sbin/halt")))) + "Handler for doshutdown event.") + (annoyme + (gexp + #~((wall "Power problems with UPS ~a. Please logoff." name))) + "Handler for annoyme event.") + (emergency + (gexp + #~((wall "Emergency Shutdown. Possible battery failure on UPS ~a." name))) + "Handler for emergency event.") + (changeme + (gexp + #~((let ((msg (format #f "~a UPS ~a battery needs changing NOW." + (gethostname) name))) + (mail-to-root msg msg)) + (wall "Emergency! Batteries have failed on UPS ~a. Change them NOW." name))) + "Handler for changeme event.") + (remotedown + (gexp + #~((wall "Remote Shutdown. Beginning Shutdown Sequence."))) + "Handler for remotedown event.") + (startselftest + (gexp + #~(#t)) + "Handler for startselftest event.") + (endselftest + (gexp + #~(#t)) + "Handler for endselftest event.") + (battdetach + (gexp + #~(#t)) + "Handler for battdetach event.") + (battattach + (gexp + #~(#t)) + "Handler for battattach event.")) + +(define-syntax define-enum + (lambda (x) + (syntax-case x () + ((_ name values) + (let* ((d/n (syntax->datum #'name)) + (d/predicate (string->symbol + (format #f "enum-~a?" d/n))) + (d/serialize (string->symbol + (format #f "serialize-enum-~a" d/n)))) + (with-syntax + ((predicate (datum->syntax x d/predicate)) + (serialize (datum->syntax x d/serialize))) + #'(begin + (define (predicate value) + (memq value values)) + (define serialize serialize-symbol)))))))) + +(define mangle-field-name + (match-lambda + ('name "UPSNAME") + ('cable "UPSCABLE") + ('type "UPSTYPE") + ('device "DEVICE") + ('poll-time "POLLTIME") + ('lock-dir "LOCKFILE") + ('power-fail-dir "PWRFAILDIR") + ('no-login-dir "NOLOGINDIR") + ('on-batery-delay "ONBATTERYDELAY") + ('battery-level "BATTERYLEVEL") + ('remaining-minutes "MINUTES") + ('timeout "TIMEOUT") + ('annoy-interval "ANNOY") + ('annoy-delay "ANNOYDELAY") + ('no-logon "NOLOGON") + ('kill-delay "KILLDELAY") + ('net-server "NETSERVER") + ('net-server-ip "NISIP") + ('net-server-port "NISPORT") + ('net-server-events-file "EVENTSFILE") + ('net-server-events-file-max-size "EVENTSFILEMAX") + ('class "UPSCLASS") + ('mode "UPSMODE") + ('stat-time "STATTIME") + ('stat-file "STATFILE") + ('log-stats "LOGSTATS") + ('data-time "DATATIME") + ('facility "FACILITY"))) + +(define (serialize-string field-name value) + #~(format #f "~a ~a\n" #$(mangle-field-name field-name) '#$value)) +(define serialize-symbol serialize-string) +(define serialize-integer serialize-string) +(define (serialize-boolean field-name value) + #~(format #f "~a ~a\n" #$(mangle-field-name field-name) #$(if value "on" "off"))) + +(define-maybe string) + +(define-enum cable '( simple smart ether usb + 940-0119A 940-0127A 940-0128A 940-0020B 940-0020C + 940-0023A 940-0024B 940-0024C 940-1524C 940-0024G + 940-0095A 940-0095B 940-0095C 940-0625A MAM-04-02-2000)) +(define-enum type '(apcsmart usb net snmp netsnmp dumb pcnet modbus test)) +(define-enum no-logon '(disable timeout percent minutes always)) +(define-enum class '(standalone shareslave sharemaster)) +(define-enum mode '(disable share)) + +(define-configuration apcupsd-configuration + (package (package apcupsd) "Package to use.") + + (shepherd-base-name + (symbol 'apcupsd) + "Base name of the shepherd service. You can add the service multiple times +with different prefix to manage multiple UPSes." + empty-serializer) + (auto-start? + (boolean #t) + "Should the shepherd service auto-start?" + empty-serializer) + (pid-file + (string "/var/run/apcupsd.pid") + "Path to the pid file." + empty-serializer) + (debug-level + (integer 0) + "Logging verbosity. Bigger number means more logs. In the source code I saw +up to @code{300}, so for all logs, @code{999} seems reasonable." + empty-serializer) + + (run-dir + (string "/var/run/apcupsd") + "Directory containing runtime information. You need to change this if you +desire to run multiple instances of the daemon." + empty-serializer) + + ;; General configuration parameters + (name + maybe-string + "Use this to give your UPS a name in log files and such. This is +particularly useful if you have multiple UPSes. This does not set the EEPROM. +It should be 8 characters or less.") + (cable + (enum-cable 'usb) + "The type of cable connecting the UPS to your computer. Possible generic +choices are @code{'simple}, @code{'smart}, @code{'ether} and +@code{'usb}. + +Or a specific cable model number may be used: @code{'940-0119A}, +@code{'940-0127A}, @code{'940-0128A}, @code{'940-0020B}, @code{'940-0020C}, +@code{'940-0023A}, @code{'940-0024B}, @code{'940-0024C}, @code{'940-1524C}, +@code{'940-0024G}, @code{'940-0095A}, @code{'940-0095B}, @code{'940-0095C}, +@code{'940-0625A}, @code{'M-04-02-2000}.") + (type + (enum-type 'usb) + "Type of the UPS you have. + +@table @code +@item apcsmart +Newer serial character device, appropriate for SmartUPS models using a serial +cable (not USB). + +@item usb +Most new UPSes are USB. + +@item net +Network link to a master apcupsd through apcupsd's Network Information Server. +This is used if the UPS powering your computer is connected to a different +computer for monitoring. + +@item snmp +SNMP network link to an SNMP-enabled UPS device. + +@item netsnmp +Same as SNMP above but requires use of the net-snmp library. Unless you have a +specific need for this old driver, you should use @code{'snmp} instead. + +@item dumb +Old serial character device for use with simple-signaling UPSes. + +@item pcnet +PowerChute Network Shutdown protocol which can be used as an alternative to SNMP +with the AP9617 family of smart slot cards. + +@item modbus +Serial device for use with newest SmartUPS models supporting the MODBUS +protocol. + +@end table") + (device + (string "") + "For USB UPSes, usually you want to set this to an empty string (the +default). For other UPS types, you must specify an appropriate port or address. + +@table @code +@item apcsmart +Set to the appropriate @file{/dev/tty**} device. + +@item usb +A null string setting enables autodetection, which is the best choice for most +installations. + +@item net +Set to @code{@var{hostname}:@var{port}}. + +@item snmp +Set to @code{@var{hostname}:@var{port}:@var{vendor}:@var{community}}. +@var{hostname} is the ip address or hostname of the UPS on the network. +@var{vendor} can be can be \"APC\" or \"APC_NOTRAP\". \"APC_NOTRAP\" will +disable SNMP trap catching; you usually want \"APC\". @var{port} is usually +161. @var{community} is usually \"private\". + +@item netsnmp +Same as @code{'snmp}. + +@item dumb +Set to the appropriate @file{/dev/tty**} device. + +@item pcnet +Set to @code{@var{ipaddr}:@var{username}:@var{passphrase}:@var{port}}. +@var{ipaddr} is the IP address of the UPS management card. @var{username} and +@var{passphrase} are the credentials for which the card has been configured. +@var{port} is the port number on which to listen for messages from the UPS, +normally 3052. If this parameter is empty or missing, the default of 3052 will +be used. + +@item modbus +Set to the appropriate @file{/dev/tty**} device. You can also leave it empty +for MODBUS over USB or set to the serial number of the UPS. + +@end table") + (poll-time + (integer 60) + "Interval (in seconds) at which apcupsd polls the UPS for status. This +setting applies both to directly-attached UPSes (apcsmart, usb, dumb) and +networked UPSes (net, snmp). Lowering this setting will improve apcupsd's +responsiveness to certain events at the cost of higher CPU utilization.") + + ;; Configuration parameters used during power failures + (on-batery-delay + (integer 6) + "The the time in seconds from when a power failure is detected until we react +to it with an onbattery event. The @code{'powerout} event will be triggered +immediately when a power failure is detected. However, the @code{'onbattery} +event will be trigger only after this delay.") + (battery-level + (integer 5) + "If during a power failure, the remaining battery percentage (as reported by +the UPS) is below or equal to this value, apcupsd will initiate a system +shutdown. + +@quotation Note +@code{battery-level}, @code{remaining-minutes}, and @code{timeout} work +in conjunction, so the first that occurs will cause the initation of a +shutdown. +@end quotation") + (remaining-minutes + (integer 3) + "If during a power failure, the remaining runtime in minutes (as calculated +internally by the UPS) is below or equal to this value, apcupsd will initiate a +system shutdown. + +@quotation Note +@code{battery-level}, @code{remaining-minutes}, and @code{timeout} work +in conjunction, so the first that occurs will cause the initation of a +shutdown. +@end quotation") + (timeout + (integer 0) + "If during a power failure, the UPS has run on batteries for this many +seconds or longer, apcupsd will initiate a system shutdown. A value of 0 +disables this timer. + +@quotation Note +@code{battery-level}, @code{remaining-minutes}, and @code{timeout} work +in conjunction, so the first that occurs will cause the initation of a +shutdown. +@end quotation") + (annoy-interval + (integer 300) + "Time in seconds between annoying users (via the @code{'annoyme} event) to +sign off prior to system shutdown. 0 disables.") + (annoy-delay + (integer 60) + "Initial delay in seconds after power failure before warning users to get off +the system.") + (no-logon + (enum-no-logon 'disable) + "The condition which determines when users are prevented from logging in +during a power failure.") + (kill-delay + (integer 0) + "If this is non-zero, apcupsd will continue running after a shutdown has been +requested, and after the specified time in seconds attempt to kill the power. +This is for use on systems where apcupsd cannot regain control after a +shutdown.") + + ;; Configuration statements for Network Information Server + (net-server + (boolean #f) + "If enabled, a network information server process will be started.") + (net-server-ip + (string "127.0.0.1") + "IP address on which NIS server will listen for incoming connections.") + (net-server-port + (integer 3551) + "IP port on which NIS server will listen for incoming connections.") + (net-server-events-file + maybe-string + "If you want the last few EVENTS to be available over the network by the +network information server, you must set this to a file patch.") + (net-server-events-file-max-size + (integer 10) + "Maximum size of the events file in kilobytes.") + ;; Configuration statements used if sharing a UPS with more than one machine + (class (enum-class 'standalone) + "Normally standalone unless you share an UPS using an APC ShareUPS card.") + (mode (enum-mode 'disable) + "Normally disable unless you share an UPS using an APC ShareUPS card.") + ;; Configuration statements to control apcupsd system logging + (stat-time + (integer 0) + "Time interval in seconds between writing the status file, 0 disables.") + (log-stats + (boolean #f) + "Also write the stats as a logs. This generates a lot of output.") + (data-time + (integer 0) + "Time interval in seconds between writing the data records to the log file, 0 +disables.") + (facility + maybe-string + "The logging facility for the syslog.") + + ;; Event handlers + (event-handlers + (apcupsd-event-handlers (apcupsd-event-handlers)) + "Handlers for events produced by apcupsd." + empty-serializer)) + +(define (s/apccontrol cfg) + (program-file + "apccontrol" + #~(begin + (use-modules (srfi srfi-9) + (ice-9 format) + (ice-9 match) + (ice-9 popen)) + ;; Script dir depends on these, and the configuration depends on the script + ;; dir. To sever the cyclic dependency, pass the paths via environment + ;; variables. + (define conf (getenv "GUIX_APCUPSD_CONF")) + (define powerfail-file (getenv "GUIX_APCUPSD_POWERFAIL_FILE")) + + (define (err . args) + (apply format (current-error-port) args)) + (define (wall . args) + (system* #$(file-append util-linux "/bin/wall") (apply format #f args))) + (define (apcupsd . args) + (apply system* #$(file-append apcupsd "/sbin/apcupsd") "-f" conf args)) + (define (mail-to-root subject body) + (let ((port (open-pipe* OPEN_WRITE + "/run/privileged/bin/sendmail" + "-F" "apcupsd" + "root"))) + (format port "Subject: ~a~%~%~a~&" subject body) + (close-pipe port))) + (match (cdr (command-line)) + (((? string? cmd) name connected powered) + (match cmd + ;; I am sure this could be done by macro, but meh. Last release of + ;; apcupsd was in 2016, so maintaining this will not be much work. + ("killpower" + #$@(apcupsd-event-handlers-killpower + (apcupsd-configuration-event-handlers cfg))) + ("commfailure" + #$@(apcupsd-event-handlers-commfailure + (apcupsd-configuration-event-handlers cfg))) + ("commok" + #$@(apcupsd-event-handlers-commok + (apcupsd-configuration-event-handlers cfg))) + ("powerout" + #$@(apcupsd-event-handlers-powerout + (apcupsd-configuration-event-handlers cfg))) + ("onbattery" + #$@(apcupsd-event-handlers-onbattery + (apcupsd-configuration-event-handlers cfg))) + ("offbattery" + #$@(apcupsd-event-handlers-offbattery + (apcupsd-configuration-event-handlers cfg))) + ("mainsback" + #$@(apcupsd-event-handlers-mainsback + (apcupsd-configuration-event-handlers cfg))) + ("failing" + #$@(apcupsd-event-handlers-failing + (apcupsd-configuration-event-handlers cfg))) + ("timeout" + #$@(apcupsd-event-handlers-timeout + (apcupsd-configuration-event-handlers cfg))) + ("loadlimit" + #$@(apcupsd-event-handlers-loadlimit + (apcupsd-configuration-event-handlers cfg))) + ("runlimit" + #$@(apcupsd-event-handlers-runlimit + (apcupsd-configuration-event-handlers cfg))) + ("doreboot" + #$@(apcupsd-event-handlers-doreboot + (apcupsd-configuration-event-handlers cfg))) + ("doshutdown" + #$@(apcupsd-event-handlers-doshutdown + (apcupsd-configuration-event-handlers cfg))) + ("annoyme" + #$@(apcupsd-event-handlers-annoyme + (apcupsd-configuration-event-handlers cfg))) + ("emergency" + #$@(apcupsd-event-handlers-emergency + (apcupsd-configuration-event-handlers cfg))) + ("changeme" + #$@(apcupsd-event-handlers-changeme + (apcupsd-configuration-event-handlers cfg))) + ("remotedown" + #$@(apcupsd-event-handlers-remotedown + (apcupsd-configuration-event-handlers cfg))) + ("startselftest" + #$@(apcupsd-event-handlers-startselftest + (apcupsd-configuration-event-handlers cfg))) + ("endselftest" + #$@(apcupsd-event-handlers-endselftest + (apcupsd-configuration-event-handlers cfg))) + ("battdetach" + #$@(apcupsd-event-handlers-battdetach + (apcupsd-configuration-event-handlers cfg))) + ("battattach" + #$@(apcupsd-event-handlers-battattach + (apcupsd-configuration-event-handlers cfg))) + (_ + (err "Unknown event: ~a~%" cmd) + (err "Iff the event was passed by apcupsd, this is a bug.~%") + (err "Please report to bug-guix@HIDDEN~%") + (exit #f)))) + (args + (err "Unknown arguments: ~a~%" args) + (err "Iff the arguments were passed by apcupsd, this is a bug.~%") + (err "Please report to bug-guix@HIDDEN~%") + (exit #f)))))) + +(define (apcupsd-script-dir cfg) + (computed-file + "apcupsd-script-dir" + #~(begin + (mkdir #$output) + (chdir #$output) + (symlink #$(s/apccontrol cfg) "apccontrol")))) + +(define (apcupsd-config-file cfg) + (let ((run-dir (apcupsd-configuration-run-dir cfg))) + (mixed-text-file + "apcupsd.conf" + "\ +## apcupsd.conf v1.1 ## +# +# for apcupsd release 3.14.14 (31 May 2016) - GNU Guix +# +# \"apcupsd\" POSIX config file (crafted via apcupsd-service-type) +" + (serialize-configuration cfg apcupsd-configuration-fields) + ;; This one is confusing. The manual page states: + ;; + ;; > It must be changed when running more than one copy of apcupsd on the + ;; > same computer to control multiple UPSes. + ;; + ;; However would you not want the lock to be per-device, not per-process? + ;; I decided to follow the documentation, but I do not understand why it + ;; should be like this. I do not have multiple UPSes to try. + (serialize-string 'lock-dir (string-append run-dir "/lock")) + (serialize-string 'power-fail-dir run-dir) + (serialize-string 'no-login-dir run-dir) + (serialize-string 'stat-file (string-append run-dir "/apcupsd.status")) + "SCRIPTDIR " (apcupsd-script-dir cfg) "\n"))) + +(define (apcupsd-shepherd-services cfg) + (match-record cfg <apcupsd-configuration> + ( package pid-file debug-level run-dir + shepherd-base-name auto-start?) + (let* ((config-file (apcupsd-config-file cfg)) + (s/ shepherd-base-name) + (s/run-dirs (string->symbol (format #f "~a-run-dirs" s/)))) + (list + (shepherd-service + (documentation "Create the run directories.") + (provision (list s/run-dirs)) + (one-shot? #t) + (auto-start? auto-start?) + (start #~(lambda _ + ((@ (guix build utils) mkdir-p) + #$(string-append run-dir "/lock")) + #t))) + (shepherd-service + (documentation "Run apcupsd daemon.") + (requirement (list s/run-dirs)) + (provision (list s/)) + (auto-start? auto-start?) + (start #~(make-forkexec-constructor + '(#$(file-append package "/sbin/apcupsd") + "-b" ; Do not daemonize. + "-f" #$config-file + "-P" #$pid-file + "-d" #$(number->string debug-level)) + #:log-file + #$(format #f "/var/log/~a.log" shepherd-base-name) + #:environment-variables + (cons* (string-append "GUIX_APCUPSD_CONF=" + #$config-file) + #$(string-append "GUIX_APCUPSD_POWERFAIL_FILE=" + run-dir "/powerfail") + (default-environment-variables)))) + (stop #~(make-kill-destructor)) + (actions (list (shepherd-configuration-action config-file)))))))) + +(define (apcupsd-pam-extensions cfg) + (define pam-nologin + (pam-entry + (control "required") + (module "pam_nologin.so") + (arguments (list (string-append "file=" + (apcupsd-configuration-run-dir cfg) + "/nologin"))))) + + (list (pam-extension + (transformer + (lambda (pam) + (pam-service + (inherit pam) + (auth (cons pam-nologin (pam-service-auth pam))))))))) + +(define apcupsd-service-type + (service-type + (name 'apcupsd) + (description "Configure and optionally start apcupsd.") + (extensions (list (service-extension shepherd-root-service-type + apcupsd-shepherd-services) + (service-extension pam-root-service-type + apcupsd-pam-extensions))) + (compose identity) + (extend (λ (cfg lst) + (fold (cut <> <>) cfg lst))) + (default-value (apcupsd-configuration)))) -- 2.47.1
X-Loop: help-debbugs@HIDDEN Subject: [bug#75528] [PATCH 1/2] gnu: Add apcupsd. Resent-From: Maxim Cournoyer <maxim.cournoyer@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Wed, 05 Feb 2025 07:00:01 +0000 Resent-Message-ID: <handler.75528.B75528.173873876520910 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 75528 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Tomas Volf <~@wolfsden.cz> Cc: 75528 <at> debbugs.gnu.org Received: via spool by 75528-submit <at> debbugs.gnu.org id=B75528.173873876520910 (code B ref 75528); Wed, 05 Feb 2025 07:00:01 +0000 Received: (at 75528) by debbugs.gnu.org; 5 Feb 2025 06:59:25 +0000 Received: from localhost ([127.0.0.1]:48082 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tfZNc-0005RA-GK for submit <at> debbugs.gnu.org; Wed, 05 Feb 2025 01:59:25 -0500 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:61761) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <maxim.cournoyer@HIDDEN>) id 1tfZNY-0005Qp-FN for 75528 <at> debbugs.gnu.org; Wed, 05 Feb 2025 01:59:22 -0500 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-2f9ba87f5d4so2567685a91.3 for <75528 <at> debbugs.gnu.org>; Tue, 04 Feb 2025 22:59:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738738754; x=1739343554; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0cOqEVYqkXp6eOC3CPacp68UTUQavTbArC7gkfA8ZBM=; b=AHdV8OyXJqRDY6wnFGH83+LiPlrPsYUAPIFG8ezd6/zuppXmkpw2Sr8rzfwNEKOXuo 05XxY9aZtEMe9Quwo6kOiXwFyErYWjuwnHB9BhNs3NDXmrVXdleP1NVOrRGFWhkob/YV CX6LNEpNP7lYSZsm1h6xGqXcP9nyMN4nIs3QvU4PA44z4bM2jeA0HFCt0huaO434DJ18 jj7oGFY3VdwSumQpE3QfmVMm1eWat1/CZUPifC4k+UDpq5AF1mmDwF4Xrdftjgjl/8Oo 8R06oJQlbKKAeRpGfCXpqRmIQ7JxFx0qoW+GvnQ3ZeEk0mb8Fy1Z0ZyhRJQWYazzi9Pc on/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738738754; x=1739343554; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0cOqEVYqkXp6eOC3CPacp68UTUQavTbArC7gkfA8ZBM=; b=mjSb2Jz+m5u1ZLBUiZyycehb2dR4P9QUK1zMBP5NrXs9b4yeBQ4qKtszQMnkHlxcZr pFft/GiQ76KUrs4jAy3gqa45++Tl/u7Cxc53zLgxDj69FZ7lRwGS4SMm2hnIrCqzYB5y yutWiF4RLiRH67kLs9cGbNjHKSTS7G6N8bdvPfkUhkZACR4HBns44RoWi5RxVlnHRQHg nVr6BRKxP63O3ZRBSOXUwq30ybwHVdoh9juYH2fUcrThMR7/G/mTRBlGM2OM7udBi3f7 mX0ObhKOWGWc09fRaI6OAXUooVmSfg/ueybsO0UQ+jP4rwdKNRojv4QRKMvmXwvhgmls U3uQ== X-Gm-Message-State: AOJu0YwMjN4rBg8XDKLH1Y4Lxn6PFGHEUpdM1H4dE1f0kO+SECwWE8gH DYqa/KkafIXkD/NEkD08c4IW7h1BNdiUdLF3qWsoYPJ1kJhIqLnq5hcUKg== X-Gm-Gg: ASbGncufk5l1amkc/UuAtg24gNU5nYiL8smJGhyUYQ2T44MP8LHvgEu5b+aZyRFxHPb /b8kO3htLqHr8RYLraYX4NnL53LlCWKquvmh+KOoqxckFUaactz++pSxtLpXXZ1hOJb572cwoec ePtv4iXnVRt6TNJDfWjeP2RsO2BqVS7Qm8Ge7oCp9uCSgibp/Nipu1W1bgb3ZJrKFnHMM1nbo5i QikJt36Zzvb3F89Y9d1A1dLVpDJ5fJ0DvSdieHj6eWQoRjTzINEwvX84muvA7U0SAJxBNXKRVyQ +XYUjTbo44EK X-Google-Smtp-Source: AGHT+IE9hiwGWVZ2wKui97uxuA6ma1b6tb+2FUEDx/nnXxWXEegnsmWt5OEu/qpsDxx9hatqkq9DOA== X-Received: by 2002:a17:90b:38c3:b0:2ee:c457:bf83 with SMTP id 98e67ed59e1d1-2f9e077dd92mr2516956a91.19.1738738753424; Tue, 04 Feb 2025 22:59:13 -0800 (PST) Received: from terra ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f9e1d60b64sm752279a91.2.2025.02.04.22.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2025 22:59:12 -0800 (PST) From: Maxim Cournoyer <maxim.cournoyer@HIDDEN> In-Reply-To: <51cba7679af5c4aa9cf0e6d70453e369ff0909d6.1736722765.git.~@wolfsden.cz> (Tomas Volf's message of "Mon, 13 Jan 2025 00:05:13 +0100") References: <cover.1736722765.git.~@wolfsden.cz> <51cba7679af5c4aa9cf0e6d70453e369ff0909d6.1736722765.git.~@wolfsden.cz> Date: Wed, 05 Feb 2025 15:59:02 +0900 Message-ID: <87jza498sp.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hi Tomas, Tomas Volf <~@wolfsden.cz> writes: > * gnu/packages/power.scm (apcupsd): New variable. 'guix lint' says: --8<---------------cut here---------------start------------->8--- gnu/packages/power.scm:120:14: apcupsd@HIDDEN: no article allowed at the b= eginning of the synopsis gnu/packages/power.scm:119:15: apcupsd@HIDDEN: TLS certificate error: X.50= 9 server certificate for 'www.apcupsd.org' does not match: CN=3Dsf.net --8<---------------cut here---------------end--------------->8--- Please fix these. > Change-Id: I74f59cd1fa2a13954117ff1683a10a84576cc839 > --- > gnu/local.mk | 1 + > gnu/packages/power.scm | 125 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 126 insertions(+) > create mode 100644 gnu/packages/power.scm > > diff --git a/gnu/local.mk b/gnu/local.mk > index 855f2acccc..6ca7bf68ac 100644 > --- a/gnu/local.mk > +++ b/gnu/local.mk > @@ -557,6 +557,7 @@ GNU_SYSTEM_MODULES =3D \ > %D%/packages/polkit.scm \ > %D%/packages/popt.scm \ > %D%/packages/potassco.scm \ > + %D%/packages/power.scm \ This change should be mentioned in the change log as well, e.g.: * gnu/local.mk (GNU_SYSTEM_MODULES): Register it. [...] > +(define-public apcupsd > + (package > + (name "apcupsd") > + (version "3.14.14") > + (source (origin > + (method url-fetch) > + (uri > + (string-append > + "mirror://sourceforge/" name "/" name " - Stable/" versi= on > + "/" name "-" version ".tar.gz")) > + (sha256 > + (base32 > + "0rwqiyzlg9p0szf3x6q1ppvrw6f6dbpn2rc5z623fk3bkdalhxyv"))= )) > + (native-inputs > + (list pkg-config python-docutils)) > + (inputs > + (list libusb libusb-compat)) nitpick: If there are less than 5 and they fit on the same line, I prefer to list them on the same line as the field name itself. That's how 'guix style' does it, although it has a tendency to protrude past our max column width of 80 guideline in other places (that's bug#62303). Also, we conventionally list the input fields below the arguments field of a package, although technically it's unimportant. > + (outputs '("out" "doc")) > + (build-system gnu-build-system) > + (arguments > + (list > + #:configure-flags > + #~(list > + ;; The configure script ignores --prefix for most of the paths. Well done with the comment. > + (string-append "--exec-prefix=3D" #$output) > + (string-append "--mandir=3D" #$output "/share/man") > + (string-append "--sbindir=3D" #$output "/sbin") > + (string-append "--sysconfdir=3D" #$output "/etc/apcupsd") > + (string-append "--with-halpolicydir=3D" #$output "/share/halpol= icy") > + > + ;; Put us into the version string. > + "--with-distname=3DGNU/Guix" The name is 'GNU Guix'. > + "--disable-install-distdir" > + > + ;; State directories. > + "--localstatedir=3D/var" > + "--with-log-dir=3D/var/log" > + "--with-pid-dir=3D/var/run" > + "--with-lock-dir=3D/var/run/apcupsd/lock" > + "--with-nologin=3D/var/run/apcupsd" > + "--with-pwrfail-dir=3D/var/run/apcupsd" I think /var/run is deprecated in favor of just /run, so we should configure the package to use this, I think. > + (string-append "ac_cv_path_SHUTDOWN=3D/nope") > + (string-append "ac_cv_path_APCUPSD_MAIL=3D/nope") > + ;; While `wall' is not expanded anywhere, it still is searched = for. > + (string-append "ac_cv_path_WALL=3D/nope") I'm not sure if this package is actively developed, but that last issue should ideally be reported (then cross-referenced here). > + ;; Enable additional drivers. > + "--enable-test" Is '--enable-test' useful? What does it do? > + "--enable-usb" > + "--enable-modbus-usb") > + #:tests? #f ; There are no tests. > + #:modules (cons '(ice-9 ftw) %default-gnu-modules) > + #:phases > + #~(modify-phases %standard-phases > + ;; These are not installed, so trick Make into thinking they w= ere > + ;; already generated. Allows us not to depend on mandoc, util= -linux. > + (add-before 'configure 'touch-txt-docs > + (lambda _ > + (for-each (lambda (f) > + (call-with-output-file f close-port)) > + '("doc/apcupsd.man.txt" > + "doc/apcaccess.man.txt" > + "doc/apctest.man.txt" > + "doc/apccontrol.man.txt" > + "doc/apcupsd.conf.man.txt")))) I think I'd rather depend on these than introduce hacks like below. These are only needed as native inputs anyway, right? > + (add-after 'build 'build-manual > + (lambda _ > + (invoke "make" "-C" "doc/manual" "manual.html"))) > + (add-after 'install-license-files 'move-doc > + (lambda _ > + (let ((target (string-append #$output:doc > + "/share/doc/" > + (strip-store-file-name #$outp= ut)))) > + (mkdir-p target) > + (for-each (lambda (f) > + (copy-file (string-append "doc/manual/" f) > + (string-append target "/" f))) > + (scandir "doc/manual" > + (lambda (f) > + (or (string-suffix? ".png" f) > + (string-suffix? ".html" f))))))= )) > + ;; If sending mails is required, use proper mail program. > + (add-after 'install 'remove-smtp > + (lambda _ > + (delete-file (string-append #$output "/sbin/smtp")))) > + ;; The configuration files and scripts are not really suitable= for > + ;; Guix, and our service provides its own version anyway. So = nuke I'd use the more peaceful 'remove' or 'delete' instead of 'nuke'. > + ;; these to make sure `apcupsd' and `apctest' executed without= any > + ;; arguments fail. `apctest' actually segfaults, but only aft= er > + ;; printing an error =C2=AF\_(=E3=83=84)_/=C2=AF. Please don't embed emojis in the source :-). > + (add-after 'install 'remove-etc-apcupsd > + (lambda _ > + (delete-file-recursively (string-append #$output "/etc/apc= upsd"))))))) Break this long line so it fits under 80 columns (our code style guideline). > + (home-page "https://www.apcupsd.org") I'd use 'http', since their TLS cert is now invalid. > + (synopsis "A daemon for controlling APC UPSes") s/A // (as hinted by 'guix lint'). > + (description "Apcupsd can be used for power mangement and controllin= g most s/mangement/management/ > +of APC=E2=80=99s UPS models on Unix and Windows machines. Apcupsd works= with most of > +APC=E2=80=99s Smart-UPS models as well as most simple signalling models = such a Back-UPS, > +and BackUPS-Office.") > + (license license:gpl2))) I think it's actually license:gpl2+, according to apcupsd-3.14.14/COPYING, which says: --8<---------------cut here---------------start------------->8--- Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. --8<---------------cut here---------------end--------------->8--- In this case for most file the last sentence applies, some other explicitly mention 'or any later version'. That's also supported by the debian/copyright file. Another thing found: the doc output doesn't build reproducibly, as shown by: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix build --no-grafts --check -K guix build: error: derivation `/gnu/store/r62j72bd3an8k2fbmaiil5hma32syxdy-= apcupsd-3.14.14.drv' may not be deterministic: output `/gnu/store/bhwkrgkqa= hgs5h8crcfyacvnwp7rj390-apcupsd-3.14.14-doc' differs from `/gnu/store/bhwkr= gkqahgs5h8crcfyacvnwp7rj390-apcupsd-3.14.14-doc-check' --8<---------------cut here---------------end--------------->8--- Let's see why: $ diff -r /gnu/store/bhwkrgkqahgs5h8crcfyacvnwp7rj390-apcupsd-3.14.14-doc{,= -check} diff -r /gnu/store/bhwkrgkqahgs5h8crcfyacvnwp7rj390-apcupsd-3.14.14-doc/sha= re/doc/apcupsd-3.14.14/manual.html /gnu/store/bhwkrgkqahgs5h8crcfyacvnwp7rj= 390-apcupsd-3.14.14-doc-check/share/doc/apcupsd-3.14.14/manual.html 376c376 < <div class=3D"line">February 5, 2025 06:54:22</div> --- > <div class=3D"line">February 5, 2025 06:54:50</div> Ah, the classic date time stamp. You'll want to neuter it in the source or in the built html file (with a preference for the former). Could you please send a v2? --=20 Thanks, Maxim
X-Loop: help-debbugs@HIDDEN Subject: [bug#75528] [PATCH 1/2] gnu: Add apcupsd. Resent-From: Maxim Cournoyer <maxim.cournoyer@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Wed, 05 Feb 2025 07:08:02 +0000 Resent-Message-ID: <handler.75528.B75528.173873923422565 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 75528 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Tomas Volf <~@wolfsden.cz> Cc: 75528 <at> debbugs.gnu.org Received: via spool by 75528-submit <at> debbugs.gnu.org id=B75528.173873923422565 (code B ref 75528); Wed, 05 Feb 2025 07:08:02 +0000 Received: (at 75528) by debbugs.gnu.org; 5 Feb 2025 07:07:14 +0000 Received: from localhost ([127.0.0.1]:48119 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tfZVC-0005rt-I0 for submit <at> debbugs.gnu.org; Wed, 05 Feb 2025 02:07:14 -0500 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:43482) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <maxim.cournoyer@HIDDEN>) id 1tfZVA-0005rf-73 for 75528 <at> debbugs.gnu.org; Wed, 05 Feb 2025 02:07:12 -0500 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2f13acbe29bso855383a91.1 for <75528 <at> debbugs.gnu.org>; Tue, 04 Feb 2025 23:07:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738739225; x=1739344025; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=4WRpCHnweP3s4tNZvxLgBxac8CYc44O51lFCsQ/8USs=; b=FdlZD8Y0RN6sImZ+ceXWJYCWsZ812Rsijq7Nu/8mW2lux+9IwiWIB5XUhDwM7zh6QY hlijDZEf/7pO1ab6ahpBLU6hFrTxC7cprZWlNk9bBvNug+UZ1KXDaJhlB4aDANJK5tS3 2/UF93lzvgmPw6C9oqLw1L8l43aLtTTQtF7WcCYfaEhCPbCpKOdYwkvtCQvMWpZDPjI1 /YFeXl4Q/HBclYE5HJmvKv/vwi0Idw17cSd2/1UfiLJZdKWPdFTY17nDJn+6jkEibAxG inBBT9NpD+30jJ4aethKYfk572F9o/+N3vbP7byVx3d3ZtLlGG0WCaJc13erZXV6IRAp 24gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738739225; x=1739344025; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4WRpCHnweP3s4tNZvxLgBxac8CYc44O51lFCsQ/8USs=; b=NDlNEL4B9SUDlMllPbq6bcmQy7HWX88HwFQmmx2x50NrSVW7bboVqr9/774rnjsoD8 o58CX+CASIQcwtNDDqDReJK5gZeURdf2wEDw4MYayZ1WE13Z84i5+2HNMDZFF1VfhHvS tVxVroWjemiPYciBMY5vf5waBf9D5HfdNh2RKCXElXtgZ6eIVayh2QFTtsn0l8+mPnYL JuB4IImThwe+zhpQRzpDyC7KSZ0Ag3n60hf3t7uYz/kQuSK5jokKG2doKbnCl6qtugxt ASTEwdKtCcWJCE8G+IPoAdHAkIj1BscfdSB2vtSw1fCgcEzKmCfSJEULrjOX23kkQlpy WJsg== X-Gm-Message-State: AOJu0Yzb0ba9AXygIxUdiEQRforBGVHIkaC6ujkeqchebGJarc2z8HtG 5iDlu7ABKzkQ8U8lmwGARkXcDAoFq1dkX2ug1yExTLkkGNx4T8VK7Fd5qg== X-Gm-Gg: ASbGncsIUiQ8KG/5pTAUaLpPLy24MLVrGj3PAovNmH5y9XqIlYqfiJHif/z8LyN7GZ+ YtU18OcKHY0/o/T50Y3y5kkAlX/PkD6Bk2VxWjPa+ZdUITCMh9UbGGyGWsrVfYzOdfhp09bgJz2 MjQy5clFDEx0SDrnJAbYXc3WyimrzTNuZjQPUhuIeszPooXup8vTCdXn7fKE9tpDnmr/m+xZIZx W/pXX2314b+vY92h6+dtIeZJnOC9esKRILjYqtnNaRS5WqxGM7xht/w3Tqe6xqyG0whpbMYGMDl vnc3ZuOg4VK+ X-Google-Smtp-Source: AGHT+IHdsmMGNzHN38iZdCv9j+/ldmH7jtFquh1KOpwfwkEtg3rD+bsH2Abj8f7rhMXlZmuX3lv4gQ== X-Received: by 2002:a05:6a00:3910:b0:728:15fd:dabb with SMTP id d2e1a72fcca58-73035203d66mr3107001b3a.8.1738739225214; Tue, 04 Feb 2025 23:07:05 -0800 (PST) Received: from terra ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72fe69ba3c1sm12119919b3a.108.2025.02.04.23.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2025 23:07:04 -0800 (PST) From: Maxim Cournoyer <maxim.cournoyer@HIDDEN> In-Reply-To: <51cba7679af5c4aa9cf0e6d70453e369ff0909d6.1736722765.git.~@wolfsden.cz> (Tomas Volf's message of "Mon, 13 Jan 2025 00:05:13 +0100") References: <cover.1736722765.git.~@wolfsden.cz> <51cba7679af5c4aa9cf0e6d70453e369ff0909d6.1736722765.git.~@wolfsden.cz> Date: Wed, 05 Feb 2025 16:06:53 +0900 Message-ID: <87frks98fm.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hi, Tomas Volf <~@wolfsden.cz> writes: > --- /dev/null > +++ b/gnu/packages/power.scm > @@ -0,0 +1,125 @@ > +;;; Copyright (C) 2025 Tomas Volf <~@wolfsden.cz> > +;;; Copyright (C) 2023 Raven Hallsby <karl@HIDDEN> One last thing; I don't see Raven listed in a 'Co-authored-by:' git trailer in the commit message; should they? Or otherwise mention plainly this work was based on their previous work, made available '$where'. -- Thanks, Maxim
X-Loop: help-debbugs@HIDDEN Subject: [bug#75528] [PATCH 2/2] services: Add power. Resent-From: Maxim Cournoyer <maxim.cournoyer@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Wed, 05 Feb 2025 13:40:01 +0000 Resent-Message-ID: <handler.75528.B75528.173876279910706 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 75528 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Tomas Volf <~@wolfsden.cz> Cc: 75528 <at> debbugs.gnu.org, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> Received: via spool by 75528-submit <at> debbugs.gnu.org id=B75528.173876279910706 (code B ref 75528); Wed, 05 Feb 2025 13:40:01 +0000 Received: (at 75528) by debbugs.gnu.org; 5 Feb 2025 13:39:59 +0000 Received: from localhost ([127.0.0.1]:49102 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tffdF-0002ma-B7 for submit <at> debbugs.gnu.org; Wed, 05 Feb 2025 08:39:59 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:57478) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <maxim.cournoyer@HIDDEN>) id 1tffdA-0002mI-QL for 75528 <at> debbugs.gnu.org; Wed, 05 Feb 2025 08:39:55 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-21f0c4275a1so24584355ad.2 for <75528 <at> debbugs.gnu.org>; Wed, 05 Feb 2025 05:39:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738762787; x=1739367587; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wGY7zRM8YeYVCVekFP9pHGwJV2AqBBWw08p9Hecat5U=; b=TSNqvDDkOwIzCtUYx+PJZQuXHsgXqCZL9G7gBZNXLAhyPbuxoMvdZ2mVeoDqtKLWlw kCZnxdtlyRPlliY83xk1s5lemPCxOpIGqarZu9tSIl0oUNT6acHVL1BA1T5E5NDnRHNY UTQgem0wjDo0IWRtb5pQ6skF4Uu0rwdddwpwbHc+vPOb0KQ7nqBQv95tlnxOjDwroJKa kFEnhLJ3DTNVW9n7EjwenlN0F1tGfSduDz5asb8SOrivPu51cSj55Ue9SzoouP0pPeGI PpQUSXPz/+9LVgkMl85jhWYYIFaHG9ZBYdtTn8VDfYdXkBTjy5AgeUpjnHO7dYWj+wHZ LKyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738762787; x=1739367587; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wGY7zRM8YeYVCVekFP9pHGwJV2AqBBWw08p9Hecat5U=; b=eTp5WBXJPjosyk2dZ3EcuIhCPTOjFptouxH0kpXhG2Z+RXcnqKaKK9I4Qs2y0R6oFW 6eqYhw6QaS/WK2olKh2h3T2t+tXzjKOjXCYFfaOx0fs+Muu8SOtDHoIWJnHH+gsq89xG 6eE3WOWsXqUBrv6er9D+BXXF6/30YIYiSJcX355s/2RKHpoZ9G1PfDH9Ra+BInC8ATH2 sg1Z75mE5TnTYjViRFq3Q6N5fjzrUJjH+G92RNV5GaYFnSc3qHrTUFhjLlGJr548Od3G wFeOv/7uWX254/qJm7fn1vpNNeDpJHFXbMIqZyple+Skfmi+sip23MBlJwuJN4Of/6JN Y3xg== X-Gm-Message-State: AOJu0YzXhRQas139yHw6hpigTmmdWH+XkTSn3vKfe01isNcpWbsoUCvq jER8llODqPSi3dyTUvT5Eafqs472XfuNkrsLnOk3utVtIK1rwJy1 X-Gm-Gg: ASbGncslRDG6yPlknB+C1vE+qrVh3Nne62NnOhq20FOu+M+d2c/p1M/CqF2ZtbNndw9 L0+sVJPai996pmmd1x1/2BCFKpe8RBpXzvXpJrK04ZX/Z6nfM/2hJtWTXXNi6bCbc/5n8RxtHwV TIqqWvp/DRkgHa2rS2KZfeXpDP/nYOYc6mSfDyXCAwgbyIVT6vWPDcY2FyeZkgb7cJqpH54A4tJ jrC1YN6bS8zSVmW9mY1sHXdbG1kRZYgn2357dFz/FLsrnpZBA1d0aoEgzvktjU4PdEVkMlH9JwU UQFN0MzNHG3o X-Google-Smtp-Source: AGHT+IEbXkoEOEZebiZnVHR7r9/IfftY56gD6ggMREb22LCirh1wndj1C+PjLexwcqAwTKT8IEgIbA== X-Received: by 2002:a17:902:e891:b0:21f:7bd:5801 with SMTP id d9443c01a7336-21f17e2cb28mr42397445ad.6.1738762786038; Wed, 05 Feb 2025 05:39:46 -0800 (PST) Received: from terra ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21f13a991fbsm17734455ad.135.2025.02.05.05.39.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 05:39:45 -0800 (PST) From: Maxim Cournoyer <maxim.cournoyer@HIDDEN> In-Reply-To: <05ba17f2babc772a26072dca72c2e6e6f852e0ad.1736722765.git.~@wolfsden.cz> (Tomas Volf's message of "Mon, 13 Jan 2025 00:05:14 +0100") References: <cover.1736722765.git.~@wolfsden.cz> <05ba17f2babc772a26072dca72c2e6e6f852e0ad.1736722765.git.~@wolfsden.cz> Date: Wed, 05 Feb 2025 22:39:33 +0900 Message-ID: <878qqk8q96.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi Tomas, Tomas Volf writes: > * gnu/services/power.scm: New file. Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (maxim.cournoyer[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:62c listed in] [list.dnswl.org] 2.0 URI_DOTEDU Has .edu URI X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hi Tomas, Tomas Volf <~@wolfsden.cz> writes: > * gnu/services/power.scm: New file. I see there's already a gnu/services/pm.scm file; it seems we don't need another one? Or was it a conscious decision? [...] > +The @code{(gnu services power)} module provides a service definition for > +@uref{http://www.apcupsd.org/, apcupsd}, a utility to interact with APC > +UPSes. Apcupsd also works with some OEM-branded products manufactured > +by APC. I'd introduce a few @acronym here to help readers, e.g. for OEM and UPS. > +@defvar apcupsd-service-type > +The service type for apcupsd. For USB UPSes no configuration is > +necessary, however tweaking some fields to better suit your needs might > +be desirable. The defaults are taken from the upstream configuration > +and they are not very conservative (@code{battery-level} of 5% is too > +low in my opinion). I'd say, (for example, the default @code{battery-level} of 5% may be considered too low by some), to keep it neutral. > +The default event handlers do send emails, read more in > +@ref{apcupsd-event-handlers}. > + > +@lisp > +(service apcupsd-service-type) > +@end lisp > +@end defvar > + > +@deftp {Data Type} apcupsd-configuration > + > +Available @code{apcupsd-configuration} fields are: > + > +@table @asis > +@item @code{package} (default: @code{apcupsd}) (type: package) > +Package to use. That's more conventionally named with the same of the package, e.g. 'acpupsd', not 'package'. I'd word the description as 'The @code{apcupsd} package to use'. > +@item @code{shepherd-base-name} (default: @code{apcupsd}) (type: symbol) > +Base name of the shepherd service. You can add the service multiple > +times with different prefix to manage multiple UPSes. s/prefix/prefixes/ aaa > + > +@item @code{auto-start?} (default: @code{#t}) (type: boolean) > +Should the shepherd service auto-start? > + > +@item @code{pid-file} (default: @code{"/var/run/apcupsd.pid"}) (type: st= ring) > +Path to the pid file. All file names becoming /run/ prefixed instead of /var/run, based on a previous comment. We don't use path in GNU to denote file names, we use 'file names'. That's mentioned in info '(standards) GNU Manuals': Please do not use the term "pathname" that is used in Unix documentation; use "file name" (two words) instead. We use the term "path" only for search paths, which are lists of directory names. > + > +@item @code{debug-level} (default: @code{0}) (type: integer) > +Logging verbosity. Bigger number means more logs. In the source code I > +saw up to @code{300}, so for all logs, @code{999} seems reasonable. I think it's best to not use first person pronoun in the manual to keep it a bit more formal. So instead of 'I saw', this could be reworded to: 'The source code uses up to @code{300} as debug level value, so a value of @code{999} seems reasonable to enable all logs.' or similar. > + > +@item @code{run-dir} (default: @code{"/var/run/apcupsd"}) (type: string) > +Directory containing runtime information. You need to change this if > +you desire to run multiple instances of the daemon. > + > +@item @code{name} (type: maybe-string) > +Use this to give your UPS a name in log files and such. This is > +particularly useful if you have multiple UPSes. This does not set the > +EEPROM. It should be 8 characters or less. > + > +@item @code{cable} (default: @code{usb}) (type: enum-cable) > +The type of cable connecting the UPS to your computer. Possible generic > +choices are @code{'simple}, @code{'smart}, @code{'ether} and > +@code{'usb}. Or a specific cable model number may be used: nitpick: I'd reword to 'Alternatively, a specific [...]', which reads better to me. [...] > +@item usb > +A null string setting enables autodetection, which is the best choice > +for most installations. nitpick: My dictionary (aspell) prefers auto-detection. [...] > +@anchor{apcupsd-event-handlers} > +@deftp {Data Type} apcupsd-event-handlers > + > +For description of the events please refer to the @command{apcupsd}'s > +manual, which can be found in the @samp{apcupsd-doc} package. I think you also meant it is in the @samp{doc} output, not in a different package, right? In any case, I'd refer them to the man page of apccontrol, which details the events. Also, to avoid the odd rendering as "the =E2=80=98apcupsd=E2=80=99=E2=80=99s manual" in info, I'd = instead rephrase to: For a description of the events please refer to @samp{man 8 apccontrol}. > + > +Each handler shall be a gexp. It is spliced into the control script for > +the daemon. In addition to the standard Guile programming environment, > +these procedures and variables are also available. s/these/the following/ [...] s/available./available:/ Since these are spliced in the control script and thus not at the top level, users won't be able to import Guile modules they may want to use, so it seems there should be a field to define which Guile modules should be imported and used by default in the configuration. > + > +@table @code > +@item conf > +Variable containing path to the configuration file. s/path/file name/, anywhere this appears. > + > +@item powerfail-file > +Variable containing path to the powerfail file. Ditto. > +@item cmd > +The event currently being handled. > + > +@item name > +The name of the UPS as specified in the configuration file. > + > +@item connected > +Is @code{"1"} if apcupsd is connected to the UPS via a serial port (or a @command{apcupsd} Also, any reason why these integer values are expressed as strings? > +USB port). In most configurations, this will be the case. In the case > +of a Slave machine where apcupsd is not directly connected to the UPS, s/Slave/slave/ ? Could be nicer to use a neutral alternative like 'follower machine'. > +this value will be @code{"0"}. > + > +@item powered > +Is @code{"1"} if the computer on which @command{apcupsd} is running is > +powered by the UPS and @code{"0"} if not. At the moment, this value is > +unimplemented and always @code{"0"}. > + > +@item (err @var{fmt} @var{args...}) > +Wrapper around @code{format} outputting to @code{(current-error-port)}. > + > +@item (wall @var{fmt} @var{args...}) > +Wrapper around @code{format} outputting via @command{wall}. > + > +@item (apcupsd @var{args...}) > +Call @command{apcupsd} while passing the correct configuration file and > +all the arguments. > + > +@item (mail-to-root @var{subject} @var{body}) > +Send an email to the local administrator. This procedure assumes the > +@command{sendmail} is located at @command{/run/privileged/bin/sendmail} > +(as would be the case with @code{opensmtpd-service-type}). > + > +@end table > + > +Available @code{apcupsd-event-handlers} fields are: > + > +@table @asis > +@item @code{killpower} (type: gexp) > +Handler for killpower event. > + > +@item @code{commfailure} (type: gexp) > +Handler for commfailure event. > + > +@item @code{commok} (type: gexp) > +Handler for commfailure event. > + > +@item @code{powerout} (type: gexp) > +Handler for powerout event. > + > +@item @code{onbattery} (type: gexp) > +Handler for onbattery event. > + > +@item @code{offbattery} (type: gexp) > +Handler for offbattery event. > + > +@item @code{mainsback} (type: gexp) > +Handler for mainsback event. > + > +@item @code{failing} (type: gexp) > +Handler for failing event. > + > +@item @code{timeout} (type: gexp) > +Handler for timeout event. > + > +@item @code{loadlimit} (type: gexp) > +Handler for loadlimit event. > + > +@item @code{runlimit} (type: gexp) > +Handler for runlimit event. > + > +@item @code{doreboot} (type: gexp) > +Handler for doreboot event. > + > +@item @code{doshutdown} (type: gexp) > +Handler for doshutdown event. > + > +@item @code{annoyme} (type: gexp) > +Handler for annoyme event. > + > +@item @code{emergency} (type: gexp) > +Handler for emergency event. > + > +@item @code{changeme} (type: gexp) > +Handler for changeme event. > + > +@item @code{remotedown} (type: gexp) > +Handler for remotedown event. > + > +@item @code{startselftest} (type: gexp) > +Handler for startselftest event. > + > +@item @code{endselftest} (type: gexp) > +Handler for endselftest event. > + > +@item @code{battdetach} (type: gexp) > +Handler for battdetach event. > + > +@item @code{battattach} (type: gexp) > +Handler for battattach event. > + > +@end table > + > +@end deftp nitpick: I'd remove the newline between the two @end above (I know, it gets generated this way...). [...] > +;;; Copyright (C) 2025 Tomas Volf <~@wolfsden.cz> We use the unicode symbol (=C2=A9) for copyright throughout Guix; please use it too, for uniformity. > + > +;;;; Commentary: > + > +;;; Power-related services. > + > +;;;; Code: > + > +(define-module (gnu services power) > + #:use-module (srfi srfi-1) > + #:use-module (srfi srfi-26) > + #:use-module (ice-9 match) > + #:use-module (gnu) > + #:use-module (gnu packages admin) > + #:use-module (gnu packages linux) > + #:use-module (gnu packages power) > + #:use-module (gnu services) > + #:use-module (gnu services configuration) > + #:use-module (gnu services shepherd) > + #:use-module (guix packages) > + #:use-module (guix records) Please order lexicographically (that is, alphabetically but on things which are not necessarily words :-)). > + #:export (apcupsd-service-type > + > + apcupsd-configuration > + apcupsd-configuration-package > + apcupsd-configuration-shepherd-base-name > + apcupsd-configuration-auto-start? > + apcupsd-configuration-pid-file > + apcupsd-configuration-debug-level > + apcupsd-configuration-run-dir > + apcupsd-configuration-name > + apcupsd-configuration-cable > + apcupsd-configuration-type > + apcupsd-configuration-device > + apcupsd-configuration-poll-time > + apcupsd-configuration-on-batery-delay > + apcupsd-configuration-battery-level > + apcupsd-configuration-remaining-minutes > + apcupsd-configuration-timeout > + apcupsd-configuration-annoy-interval > + apcupsd-configuration-annoy-delay > + apcupsd-configuration-no-logon > + apcupsd-configuration-kill-delay > + apcupsd-configuration-net-server > + apcupsd-configuration-net-server-ip > + apcupsd-configuration-net-server-port > + apcupsd-configuration-net-server-events-file > + apcupsd-configuration-net-server-events-file-max-size > + apcupsd-configuration-class > + apcupsd-configuration-mode > + apcupsd-configuration-stat-time > + apcupsd-configuration-log-stats > + apcupsd-configuration-data-time > + apcupsd-configuration-facility > + apcupsd-configuration-event-handlers > + > + apcupsd-event-handlers-annoyme > + apcupsd-event-handlers-battattach > + apcupsd-event-handlers-battdetach > + apcupsd-event-handlers-changeme > + apcupsd-event-handlers-commfailure > + apcupsd-event-handlers-commok > + apcupsd-event-handlers-doreboot > + apcupsd-event-handlers-doshutdown > + apcupsd-event-handlers-emergency > + apcupsd-event-handlers-endselftest > + apcupsd-event-handlers-failing > + apcupsd-event-handlers-killpower > + apcupsd-event-handlers-loadlimit > + apcupsd-event-handlers-mainsback > + apcupsd-event-handlers-offbattery > + apcupsd-event-handlers-onbattery > + apcupsd-event-handlers-powerout > + apcupsd-event-handlers-remotedown > + apcupsd-event-handlers-runlimit > + apcupsd-event-handlers-startselftest > + apcupsd-event-handlers-timeout)) > + > +(define-configuration/no-serialization apcupsd-event-handlers > + (killpower > + (gexp > + #~((wall "Apccontrol doing: apcupsd --killpower on UPS ~a" name) > + (sleep 10) > + (apcupsd "--killpower") > + (wall "Apccontrol has done: apcupsd --killpower on UPS ~a" name))) > + "Handler for killpower event.") In many places in your writing, I find that it skips adding 'the' (definite article), which I've learned should be use when describing something specific, such as here with the specific handlers: "Handler for the @code{killpower} event." In case it helps, I've found this page seems useful in briefly explaining when to use 'the' [0]. [0] https://owl.purdue.edu/owl/general_writing/grammar/using_articles.html > + (commfailure > + (gexp > + #~((let ((msg (format #f "~a Communications with UPS ~a lost." > + (gethostname) name))) > + (mail-to-root msg msg)) > + (wall "Warning: communications lost with UPS ~a" name))) > + "Handler for commfailure event.") > + (commok > + (gexp > + #~((let ((msg (format #f "~a Communications with UPS ~a restored." > + (gethostname) name))) > + (mail-to-root msg msg)) > + (wall "Communications restored with UPS ~a" name))) > + "Handler for commfailure event.") > + (powerout > + (gexp > + #~(#t)) > + "Handler for powerout event.") > + (onbattery > + (gexp > + #~((let ((msg (format #f "~a UPS ~a Power Failure !!!" > + (gethostname) name))) > + (mail-to-root msg msg)) > + (wall "Power failure on UPS ~a. Running on batteries." name))) > + "Handler for onbattery event.") > + (offbattery > + (gexp > + #~((let ((msg (format #f "~a UPS ~a Power has returned." > + (gethostname) name))) > + (mail-to-root msg msg)) > + (wall "Power has returned on UPS ~a..." name))) > + "Handler for offbattery event.") > + (mainsback > + (gexp > + #~((when (file-exists? powerfail-file) > + (wall "Continuing with shutdown.")))) > + "Handler for mainsback event.") > + (failing > + (gexp > + #~((wall "Battery power exhausted on UPS ~a. Doing shutdown." name)= )) > + "Handler for failing event.") > + (timeout > + (gexp > + #~((wall "Battery time limit exceeded on UPS ~a. Doing shutdown." n= ame))) > + "Handler for timeout event.") > + (loadlimit > + (gexp > + #~((wall "Remaining battery charge below limit on UPS ~a. Doing shu= tdown." name))) > + "Handler for loadlimit event.") > + (runlimit > + (gexp > + #~((wall "Remaining battery runtime below limit on UPS ~a. Doing sh= utdown." name))) > + "Handler for runlimit event.") > + (doreboot > + (gexp > + #~((wall "UPS ~a initiating Reboot Sequence" name) > + (system* #$(file-append shepherd "/sbin/reboot")))) > + "Handler for doreboot event.") > + (doshutdown > + (gexp > + #~((wall "UPS ~a initiated Shutdown Sequence" name) > + (system* #$(file-append shepherd "/sbin/halt")))) > + "Handler for doshutdown event.") > + (annoyme > + (gexp > + #~((wall "Power problems with UPS ~a. Please logoff." name))) > + "Handler for annoyme event.") > + (emergency > + (gexp > + #~((wall "Emergency Shutdown. Possible battery failure on UPS ~a." = name))) > + "Handler for emergency event.") > + (changeme > + (gexp > + #~((let ((msg (format #f "~a UPS ~a battery needs changing NOW." > + (gethostname) name))) > + (mail-to-root msg msg)) > + (wall "Emergency! Batteries have failed on UPS ~a. Change them = NOW." name))) > + "Handler for changeme event.") > + (remotedown > + (gexp > + #~((wall "Remote Shutdown. Beginning Shutdown Sequence."))) > + "Handler for remotedown event.") > + (startselftest > + (gexp > + #~(#t)) > + "Handler for startselftest event.") > + (endselftest > + (gexp > + #~(#t)) > + "Handler for endselftest event.") > + (battdetach > + (gexp > + #~(#t)) > + "Handler for battdetach event.") > + (battattach > + (gexp > + #~(#t)) > + "Handler for battattach event.")) Sounds fun :-). I was wondering if the handlers could be of the maybe-gexp type, and when not provided the handler would not be called at all? Or does the design of apcupsd mandates that all handlers be defined? > +(define-syntax define-enum > + (lambda (x) > + (syntax-case x () > + ((_ name values) > + (let* ((d/n (syntax->datum #'name)) > + (d/predicate (string->symbol > + (format #f "enum-~a?" d/n))) > + (d/serialize (string->symbol > + (format #f "serialize-enum-~a" d/n)))) Even for internal bindings, better variable names would help reading the code. > + (with-syntax > + ((predicate (datum->syntax x d/predicate)) > + (serialize (datum->syntax x d/serialize))) > + #'(begin > + (define (predicate value) > + (memq value values)) > + (define serialize serialize-symbol)))))))) That is a nice minimal enum for using with define-configuration. Note that Guile has some kind of very limited enum from (rnrs enums), but I don't think they'd be too useful here. See for example 'make-enumeration' from (rnrs enums), which I used in for the ntp-server-types in (gnu services networking). > +(define mangle-field-name > + (match-lambda > + ('name "UPSNAME") > + ('cable "UPSCABLE") > + ('type "UPSTYPE") > + ('device "DEVICE") > + ('poll-time "POLLTIME") > + ('lock-dir "LOCKFILE") > + ('power-fail-dir "PWRFAILDIR") > + ('no-login-dir "NOLOGINDIR") > + ('on-batery-delay "ONBATTERYDELAY") > + ('battery-level "BATTERYLEVEL") > + ('remaining-minutes "MINUTES") > + ('timeout "TIMEOUT") > + ('annoy-interval "ANNOY") > + ('annoy-delay "ANNOYDELAY") > + ('no-logon "NOLOGON") > + ('kill-delay "KILLDELAY") > + ('net-server "NETSERVER") > + ('net-server-ip "NISIP") > + ('net-server-port "NISPORT") > + ('net-server-events-file "EVENTSFILE") > + ('net-server-events-file-max-size "EVENTSFILEMAX") > + ('class "UPSCLASS") > + ('mode "UPSMODE") > + ('stat-time "STATTIME") > + ('stat-file "STATFILE") > + ('log-stats "LOGSTATS") > + ('data-time "DATATIME") > + ('facility "FACILITY"))) > + > +(define (serialize-string field-name value) > + #~(format #f "~a ~a\n" #$(mangle-field-name field-name) '#$value)) > +(define serialize-symbol serialize-string) > +(define serialize-integer serialize-string) > +(define (serialize-boolean field-name value) > + #~(format #f "~a ~a\n" #$(mangle-field-name field-name) #$(if value "o= n" "off"))) You'll want to break the above line. > + > +(define-maybe string) > + > +(define-enum cable '( simple smart ether usb > + 940-0119A 940-0127A 940-0128A 940-0020B 940-0020C > + 940-0023A 940-0024B 940-0024C 940-1524C 940-0024G > + 940-0095A 940-0095B 940-0095C 940-0625A MAM-04-02-= 2000)) > +(define-enum type '(apcsmart usb net snmp netsnmp dumb pcnet modbus test= )) > +(define-enum no-logon '(disable timeout percent minutes always)) > +(define-enum class '(standalone shareslave sharemaster)) > +(define-enum mode '(disable share)) > + > +(define-configuration apcupsd-configuration > + (package (package apcupsd) "Package to use.") Please stick to the convention where the name of the package is the name of the field used to specify such package (here: apcupsd). > + (shepherd-base-name > + (symbol 'apcupsd) > + "Base name of the shepherd service. You can add the service multiple= times > +with different prefix to manage multiple UPSes." > + empty-serializer) > + (auto-start? > + (boolean #t) > + "Should the shepherd service auto-start?" > + empty-serializer) > + (pid-file > + (string "/var/run/apcupsd.pid") /var/run -> /run (adjust everywhere) > + "Path to the pid file." I'm repeating myself because I reviewed the texi produced from this, but yeah, s/path/file name/, and make sure to adjust the rest of the comments I made for the .texi in the source (I'd just edit the source and regenerate the doc from it). [...] > +(define (s/apccontrol cfg) what is the 's/' prefix for in the procedure name? 'serialize'? Spell this out in full to be clear rather than cryptic (that's a convention followed at large in general in Scheme). > + (program-file > + "apccontrol" > + #~(begin > + (use-modules (srfi srfi-9) > + (ice-9 format) > + (ice-9 match) > + (ice-9 popen)) Please sort modules lexicographically. > + ;; Script dir depends on these, and the configuration depends on = the script > + ;; dir. To sever the cyclic dependency, pass the paths via envir= onment > + ;; variables. > + (define conf (getenv "GUIX_APCUPSD_CONF")) > + (define powerfail-file (getenv "GUIX_APCUPSD_POWERFAIL_FILE")) > + > + (define (err . args) > + (apply format (current-error-port) args)) > + (define (wall . args) > + (system* #$(file-append util-linux "/bin/wall") (apply format #= f args))) > + (define (apcupsd . args) > + (apply system* #$(file-append apcupsd "/sbin/apcupsd") "-f" con= f args)) > + (define (mail-to-root subject body) > + (let ((port (open-pipe* OPEN_WRITE > + "/run/privileged/bin/sendmail" > + "-F" "apcupsd" > + "root"))) > + (format port "Subject: ~a~%~%~a~&" subject body) > + (close-pipe port))) > + (match (cdr (command-line)) > + (((? string? cmd) name connected powered) > + (match cmd > + ;; I am sure this could be done by macro, but meh. Last rel= ease of > + ;; apcupsd was in 2016, so maintaining this will not be much= work. > + ("killpower" > + #$@(apcupsd-event-handlers-killpower > + (apcupsd-configuration-event-handlers cfg))) > + ("commfailure" > + #$@(apcupsd-event-handlers-commfailure > + (apcupsd-configuration-event-handlers cfg))) > + ("commok" > + #$@(apcupsd-event-handlers-commok > + (apcupsd-configuration-event-handlers cfg))) > + ("powerout" > + #$@(apcupsd-event-handlers-powerout > + (apcupsd-configuration-event-handlers cfg))) > + ("onbattery" > + #$@(apcupsd-event-handlers-onbattery > + (apcupsd-configuration-event-handlers cfg))) > + ("offbattery" > + #$@(apcupsd-event-handlers-offbattery > + (apcupsd-configuration-event-handlers cfg))) > + ("mainsback" > + #$@(apcupsd-event-handlers-mainsback > + (apcupsd-configuration-event-handlers cfg))) > + ("failing" > + #$@(apcupsd-event-handlers-failing > + (apcupsd-configuration-event-handlers cfg))) > + ("timeout" > + #$@(apcupsd-event-handlers-timeout > + (apcupsd-configuration-event-handlers cfg))) > + ("loadlimit" > + #$@(apcupsd-event-handlers-loadlimit > + (apcupsd-configuration-event-handlers cfg))) > + ("runlimit" > + #$@(apcupsd-event-handlers-runlimit > + (apcupsd-configuration-event-handlers cfg))) > + ("doreboot" > + #$@(apcupsd-event-handlers-doreboot > + (apcupsd-configuration-event-handlers cfg))) > + ("doshutdown" > + #$@(apcupsd-event-handlers-doshutdown > + (apcupsd-configuration-event-handlers cfg))) > + ("annoyme" > + #$@(apcupsd-event-handlers-annoyme > + (apcupsd-configuration-event-handlers cfg))) > + ("emergency" > + #$@(apcupsd-event-handlers-emergency > + (apcupsd-configuration-event-handlers cfg))) > + ("changeme" > + #$@(apcupsd-event-handlers-changeme > + (apcupsd-configuration-event-handlers cfg))) > + ("remotedown" > + #$@(apcupsd-event-handlers-remotedown > + (apcupsd-configuration-event-handlers cfg))) > + ("startselftest" > + #$@(apcupsd-event-handlers-startselftest > + (apcupsd-configuration-event-handlers cfg))) > + ("endselftest" > + #$@(apcupsd-event-handlers-endselftest > + (apcupsd-configuration-event-handlers cfg))) > + ("battdetach" > + #$@(apcupsd-event-handlers-battdetach > + (apcupsd-configuration-event-handlers cfg))) > + ("battattach" > + #$@(apcupsd-event-handlers-battattach > + (apcupsd-configuration-event-handlers cfg))) > + (_ > + (err "Unknown event: ~a~%" cmd) > + (err "Iff the event was passed by apcupsd, this is a bug.~%= ") s/Iff/If/, perhaps s/passed/emitted/. I don't understand, in which scenario would an event *not* be emitted by apcupsd? > + (err "Please report to bug-guix@HIDDEN~%") > + (exit #f)))) > + (args > + (err "Unknown arguments: ~a~%" args) > + (err "Iff the arguments were passed by apcupsd, this is a bug.= ~%") s/Iff/If/ > + (err "Please report to bug-guix@HIDDEN~%") > + (exit #f)))))) > + > +(define (apcupsd-script-dir cfg) s/cfg/config/ > + (computed-file > + "apcupsd-script-dir" > + #~(begin > + (mkdir #$output) > + (chdir #$output) > + (symlink #$(s/apccontrol cfg) "apccontrol")))) > + > +(define (apcupsd-config-file cfg) s/cfg/config/ > + (let ((run-dir (apcupsd-configuration-run-dir cfg))) > + (mixed-text-file > + "apcupsd.conf" > + "\ > +## apcupsd.conf v1.1 ## > +# > +# for apcupsd release 3.14.14 (31 May 2016) - GNU Guix Is this config really bound to a version like above? Unless they change things in backward incompatible ways, it should work for newer ones too, no? > +# > +# \"apcupsd\" POSIX config file (crafted via apcupsd-service-type) s/crafted via/auto-generated by/ > +" > + (serialize-configuration cfg apcupsd-configuration-fields) > + ;; This one is confusing. The manual page states: > + ;; > + ;; > It must be changed when running more than one copy of apcupsd = on the > + ;; > same computer to control multiple UPSes. > + ;; > + ;; However would you not want the lock to be per-device, not per-pr= ocess? > + ;; I decided to follow the documentation, but I do not understand w= hy it > + ;; should be like this. I do not have multiple UPSes to try. > + (serialize-string 'lock-dir (string-append run-dir "/lock")) > + (serialize-string 'power-fail-dir run-dir) > + (serialize-string 'no-login-dir run-dir) > + (serialize-string 'stat-file (string-append run-dir "/apcupsd.statu= s")) > + "SCRIPTDIR " (apcupsd-script-dir cfg) "\n"))) > + > +(define (apcupsd-shepherd-services cfg) s/cfg/config/ > + (match-record cfg <apcupsd-configuration> > + ( package pid-file debug-level run-dir ^ extraneous space =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > + shepherd-base-name auto-start?) > + (let* ((config-file (apcupsd-config-file cfg)) > + (s/ shepherd-base-name) Please improve the variables names a bit; what is 's/' ? > + (s/run-dirs (string->symbol (format #f "~a-run-dirs" s/)))) > + (list > + (shepherd-service > + (documentation "Create the run directories.") > + (provision (list s/run-dirs)) > + (one-shot? #t) > + (auto-start? auto-start?) > + (start #~(lambda _ > + ((@ (guix build utils) mkdir-p) > + #$(string-append run-dir "/lock")) > + #t))) Is there a reason why this is not done in an activation script instead? That's more conventional, I think. > + (shepherd-service > + (documentation "Run apcupsd daemon.") Run *the* apcupsd daemon. > + (requirement (list s/run-dirs)) > + (provision (list s/)) > + (auto-start? auto-start?) > + (start #~(make-forkexec-constructor > + '(#$(file-append package "/sbin/apcupsd") > + "-b" ; Do not daemonize. If you want, margin comments are ok without space or full sentence (punctuation), e.g.: --8<---------------cut here---------------start------------->8--- ;do not daemonize --8<---------------cut here---------------end--------------->8--- =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > + "-f" #$config-file > + "-P" #$pid-file > + "-d" #$(number->string debug-level)) > + #:log-file > + #$(format #f "/var/log/~a.log" shepherd-base-name) > + #:environment-variables > + (cons* (string-append "GUIX_APCUPSD_CONF=3D" > + #$config-file) > + #$(string-append "GUIX_APCUPSD_POWERFAIL_FILE= =3D" > + run-dir "/powerfail") > + (default-environment-variables)))) > + (stop #~(make-kill-destructor)) > + (actions (list (shepherd-configuration-action config-file)))))))) > + > +(define (apcupsd-pam-extensions cfg) s/cfg/config/ > + (define pam-nologin A comment explaining why this PAM extention is required would be helpful (I have no idea myself -- but I must confess: PAM is still a bit of a mystery to me). > + (pam-entry > + (control "required") > + (module "pam_nologin.so") > + (arguments (list (string-append "file=3D" > + (apcupsd-configuration-run-dir cfg) > + "/nologin"))))) > + > + (list (pam-extension > + (transformer > + (lambda (pam) > + (pam-service > + (inherit pam) > + (auth (cons pam-nologin (pam-service-auth pam))))))))) > + > +(define apcupsd-service-type > + (service-type > + (name 'apcupsd) > + (description "Configure and optionally start apcupsd.") > + (extensions (list (service-extension shepherd-root-service-type > + apcupsd-shepherd-services) > + (service-extension pam-root-service-type > + apcupsd-pam-extensions))) > + (compose identity) > + (extend (=CE=BB (cfg lst) nitpick: There was a stylistic choice to prefer lambda instead of =CE=BB in the Guix code base to try to make it more accessible at some point. > + (fold (cut <> <>) cfg lst))) > + (default-value (apcupsd-configuration)))) Thanks for this very complete, carefully and thoughtfully crafted contribution. As you can see, the only comments I had were mostly nitpicks and small details. I look forward to the next revision. --=20 Thanks, Maxim
X-Loop: help-debbugs@HIDDEN Subject: [bug#75528] [PATCH 1/2] gnu: Add apcupsd. Resent-From: Tomas Volf <~@wolfsden.cz> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Sun, 09 Feb 2025 16:12:02 +0000 Resent-Message-ID: <handler.75528.B75528.173911746218903 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 75528 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer <maxim.cournoyer@HIDDEN> Cc: 75528 <at> debbugs.gnu.org Received: via spool by 75528-submit <at> debbugs.gnu.org id=B75528.173911746218903 (code B ref 75528); Sun, 09 Feb 2025 16:12:02 +0000 Received: (at 75528) by debbugs.gnu.org; 9 Feb 2025 16:11:02 +0000 Received: from localhost ([127.0.0.1]:45924 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1th9td-0004uU-0u for submit <at> debbugs.gnu.org; Sun, 09 Feb 2025 11:11:02 -0500 Received: from wolfsden.cz ([37.205.8.62]:37850) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1th9tZ-0004uI-1u for 75528 <at> debbugs.gnu.org; Sun, 09 Feb 2025 11:10:58 -0500 Received: by wolfsden.cz (Postfix, from userid 104) id BBD673251F5; Sun, 9 Feb 2025 16:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1739117454; bh=7rNLQyoGFWV4NZsFfD6Nr6J2im9YGM5IRuSuolrXIZQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=YNTLtYWX6WnQdyMQ1saB5NPNG363yyZBBjAKmZONyHcVo6g5232Lo3LLxzztiXu8O uESZNpqM4VwP7wLQp0ZVafespZd3yEFz+Ka+7z7FGy+YqgZqvMsAWiTJ7q7xXLniCP QroOSYzsc+BeWQ83K8ZqGRQV8MbxRNZAnQVc65tKVhuMcugL3vVwmpn12cUfDN5j8t 6wFiLftS4iapkjcC0bW82pQJTA9S+qI/ODWGMv9NSvzlNd+T8vvnmAzciuXxJG17QD OXqnDp5tlDQWErnfQZ9pAXs0HhkG0KNztNVnTRWFvkCl1f/UXWWtDY6tOfmhAamX3O N1cvyt2oAzRTfh4L1QL/y4XkBiVdcPOUdcIAEuNWLg6GpEaJaKPh9Q9ecPYIPrXCPD Lf5MRsDNoRXASnUvjN2fLgLmHBMaGwGfSjhjpQujZeu2xe9BECDkJfZ3d6+vrbhdix PvtgG5Wfw0smMjg79y4HLlkO0JUxX+27u0nZ/VvvTcvBeL69WFp79tsIe7Hfh0/2Xm 64XNNwnZMxlKlY8N19qqMZRMXe2grlFqhxWQ4g13acOi2UM0sNiuPaoiXMJkeCgYr8 aPOSOzxO7wLVv4yHBxLaYSl0H21dYvb92iEud/K6iIV7JH6uyB/v6qYru+d0WtLY/B YyGt2qiRW5LXK3/AIO8eD34Y= X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on wolfsden X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id 4C36A326506; Sun, 9 Feb 2025 16:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1739117452; bh=7rNLQyoGFWV4NZsFfD6Nr6J2im9YGM5IRuSuolrXIZQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=ERF5sLn/uxy7DB3yUY3pa1hT2Ll9fHiE6vqgmbAheOa/+UjO9nCWu7jwTscM6MMQG w1ZNaqxTXqVtmb+teGs4DHHl37WkL2sBPvBk4x4ArK99yjJVoRA3B4hrtSOKJqCd5V JRJQHaR/rUD10WWDo+zk5j9v7wuOU1I1kDukLlyn14LlLk+qBerkLsjZk72M6jbOlX Bu8F6znJKOGK27CxxnsRaPODA1nwfpxZXEPsEd9QYZXirwchw/TL7/0SSJ3vjwSewO MqtmlrvpMlmno6W6tIM12iteuom38OHVfv6jkRXBo1Y8SCMQpM6tP5IVw0oNkZgSNS 9bDTeR0C6AGJh5TIbYy0m2prM2lCZi8CBFKq0gRm1/f5IqaXtE5Hej82mv2YV7w7K7 ptDtEv5daZ99SjNN6dmgGUO7c166/ZsS71vTKeul8Y+zt+x+3viI12+/hUiH1st82M RnzItilQlc9QsBZOOI3rFdfYdtNmttmX1L/SPcWkmt29aRFcSA06MgSz+/WoKf0UJ/ IYfwO9+EZJrLOQP/pO6tzW6VLUz4k1TR/lZMgtJT17K+EySQnBqBfiV42xp0rn19HA L0ZhqtrT3hx8LgunViqTlw9D13zSc39ShpioGMT7kKlHSUiE0wN1XY6Wrqc241rZ0t ozShY2XiK1BLss6T7w/6V1HE= From: Tomas Volf <~@wolfsden.cz> In-Reply-To: <87jza498sp.fsf@HIDDEN> (Maxim Cournoyer's message of "Wed, 05 Feb 2025 15:59:02 +0900") References: <cover.1736722765.git.~@wolfsden.cz> <51cba7679af5c4aa9cf0e6d70453e369ff0909d6.1736722765.git.~@wolfsden.cz> <87jza498sp.fsf@HIDDEN> Date: Sun, 09 Feb 2025 17:10:51 +0100 Message-ID: <87pljrf69g.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Maxim, thank you for the review, replies below. Maxim Cournoyer <maxim.cournoyer@HIDDEN> writes: > Hi Tomas, > > Tomas Volf <~@wolfsden.cz> writes: > >> * gnu/packages/power.scm (apcupsd): New variable. > > 'guix lint' says: > > gnu/packages/power.scm:120:14: apcupsd@HIDDEN: no article allowed at the= beginning of the synopsis > gnu/packages/power.scm:119:15: apcupsd@HIDDEN: TLS certificate error: X.= 509 server certificate for 'www.apcupsd.org' does not match: CN=3Dsf.net > > > Please fix these. Both fixed. > >> Change-Id: I74f59cd1fa2a13954117ff1683a10a84576cc839 >> --- >> gnu/local.mk | 1 + >> gnu/packages/power.scm | 125 +++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 126 insertions(+) >> create mode 100644 gnu/packages/power.scm >> >> diff --git a/gnu/local.mk b/gnu/local.mk >> index 855f2acccc..6ca7bf68ac 100644 >> --- a/gnu/local.mk >> +++ b/gnu/local.mk >> @@ -557,6 +557,7 @@ GNU_SYSTEM_MODULES =3D \ >> %D%/packages/polkit.scm \ >> %D%/packages/popt.scm \ >> %D%/packages/potassco.scm \ >> + %D%/packages/power.scm \ > > This change should be mentioned in the change log as well, e.g.: > > * gnu/local.mk (GNU_SYSTEM_MODULES): Register it. > > [...] I used slightly different message, since the previous line mentions "new variable", but the object being registered is whole file. > >> +(define-public apcupsd >> + (package >> + (name "apcupsd") >> + (version "3.14.14") >> + (source (origin >> + (method url-fetch) >> + (uri >> + (string-append >> + "mirror://sourceforge/" name "/" name " - Stable/" vers= ion >> + "/" name "-" version ".tar.gz")) >> + (sha256 >> + (base32 >> + "0rwqiyzlg9p0szf3x6q1ppvrw6f6dbpn2rc5z623fk3bkdalhxyv")= ))) >> + (native-inputs >> + (list pkg-config python-docutils)) >> + (inputs >> + (list libusb libusb-compat)) > > nitpick: If there are less than 5 and they fit on the same line, I > prefer to list them on the same line as the field name itself. That's > how 'guix style' does it, although it has a tendency to protrude past > our max column width of 80 guideline in other places (that's > bug#62303). Fair enough. I do not have strong preference, so I have made it into a single line. I have to admit I do not run `guix style' (yes, yes, I know contributing part of the manual mandates it), since the code produced is often subpar compared to the hand-crafted variant. > > Also, we conventionally list the input fields below the arguments field > of a package, although technically it's unimportant. Moved. > >> + (outputs '("out" "doc")) >> + (build-system gnu-build-system) >> + (arguments >> + (list >> + #:configure-flags >> + #~(list >> + ;; The configure script ignores --prefix for most of the paths. > > Well done with the comment. > >> + (string-append "--exec-prefix=3D" #$output) >> + (string-append "--mandir=3D" #$output "/share/man") >> + (string-append "--sbindir=3D" #$output "/sbin") >> + (string-append "--sysconfdir=3D" #$output "/etc/apcupsd") >> + (string-append "--with-halpolicydir=3D" #$output "/share/halpo= licy") >> + >> + ;; Put us into the version string. >> + "--with-distname=3DGNU/Guix" > > The name is 'GNU Guix'. I was afraid of the space. :) But seems to work fine, changed. > >> + "--disable-install-distdir" >> + >> + ;; State directories. >> + "--localstatedir=3D/var" >> + "--with-log-dir=3D/var/log" >> + "--with-pid-dir=3D/var/run" >> + "--with-lock-dir=3D/var/run/apcupsd/lock" >> + "--with-nologin=3D/var/run/apcupsd" >> + "--with-pwrfail-dir=3D/var/run/apcupsd" > > I think /var/run is deprecated in favor of just /run, so we should > configure the package to use this, I think. It seems pretty much all programs on my system are using /var/run, including Shepherd. Only programs that store information in /run seem to be elogind and dbus. Is deprecation of /var/run listed somewhere in the manual? I am surprised Shepherd (since it is actively maintained and core component) is still in /var/run. I looked and found 42 references to /var/run, but none with the deprecation notice. Assuming you will insist on moving it to /run, is there some structure to follow in that directory? Or just s~/var/run~/run~? What about /var and /var/log? Should those be moved somewhere as well? > >> + (string-append "ac_cv_path_SHUTDOWN=3D/nope") >> + (string-append "ac_cv_path_APCUPSD_MAIL=3D/nope") >> + ;; While `wall' is not expanded anywhere, it still is searched= for. >> + (string-append "ac_cv_path_WALL=3D/nope") > > I'm not sure if this package is actively developed, but that last issue > should ideally be reported (then cross-referenced here). I did not found a way to report a bug. Nothing is listed in the manual, and their apcupsd-users mailing list requires JavaScript to sign up (and does not tell me the email address otherwise). I did try to blindly send an email, will see if it will be accepted without being subscribed. If that happens, I will add the link here. > >> + ;; Enable additional drivers. >> + "--enable-test" > > Is '--enable-test' useful? What does it do? According to the manual =2D-8<---------------cut here---------------start------------->8--- This turns on a test driver that is used only for debugging. =2D-8<---------------cut here---------------end--------------->8--- Since there does not seem to be any harm in having it on, I enabled it, since Guix seems to aim for feature complete packages (I assume that is the reason for everything being so large). But I have no use for it, so I can turn it off if you would prefer. > >> + "--enable-usb" >> + "--enable-modbus-usb") >> + #:tests? #f ; There are no tests. >> + #:modules (cons '(ice-9 ftw) %default-gnu-modules) >> + #:phases >> + #~(modify-phases %standard-phases >> + ;; These are not installed, so trick Make into thinking they = were >> + ;; already generated. Allows us not to depend on mandoc, uti= l-linux. >> + (add-before 'configure 'touch-txt-docs >> + (lambda _ >> + (for-each (lambda (f) >> + (call-with-output-file f close-port)) >> + '("doc/apcupsd.man.txt" >> + "doc/apcaccess.man.txt" >> + "doc/apctest.man.txt" >> + "doc/apccontrol.man.txt" >> + "doc/apcupsd.conf.man.txt")))) > > I think I'd rather depend on these than introduce hacks like below. The "hacks" *below* would still be required. The HTML manual is not built nor installed by default, and there is no target to invoke to install them. So both 'build-manual and 'move-doc phases would still be required. We could get rid of the "hack" *above* ('touch-txt-docs), true. It is worth those two additional inputs? > These are only needed as native inputs anyway, right? Yes. > >> + (add-after 'build 'build-manual >> + (lambda _ >> + (invoke "make" "-C" "doc/manual" "manual.html"))) >> + (add-after 'install-license-files 'move-doc >> + (lambda _ >> + (let ((target (string-append #$output:doc >> + "/share/doc/" >> + (strip-store-file-name #$out= put)))) >> + (mkdir-p target) >> + (for-each (lambda (f) >> + (copy-file (string-append "doc/manual/" f) >> + (string-append target "/" f))) >> + (scandir "doc/manual" >> + (lambda (f) >> + (or (string-suffix? ".png" f) >> + (string-suffix? ".html" f)))))= ))) >> + ;; If sending mails is required, use proper mail program. >> + (add-after 'install 'remove-smtp >> + (lambda _ >> + (delete-file (string-append #$output "/sbin/smtp")))) >> + ;; The configuration files and scripts are not really suitabl= e for >> + ;; Guix, and our service provides its own version anyway. So= nuke > > I'd use the more peaceful 'remove' or 'delete' instead of 'nuke'. Uh, sure. Done. > >> + ;; these to make sure `apcupsd' and `apctest' executed withou= t any >> + ;; arguments fail. `apctest' actually segfaults, but only af= ter >> + ;; printing an error =C2=AF\_(=E3=83=84)_/=C2=AF. > > Please don't embed emojis in the source :-). Technically kaomoji (=E9=A1=94=E6=96=87=E5=AD=97), not emoji (=E7=B5=B5=E6= =96=87=E5=AD=97), but point taken. :) > >> + (add-after 'install 'remove-etc-apcupsd >> + (lambda _ >> + (delete-file-recursively (string-append #$output "/etc/ap= cupsd"))))))) > > Break this long line so it fits under 80 columns (our code style > guideline). I thought (well, still do), that going 4 characters over the limit was worth the increase in readability. Nevertheless, I have split it into two lines. > >> + (home-page "https://www.apcupsd.org") > > I'd use 'http', since their TLS cert is now invalid. Done as part of resolving the ling warning. > >> + (synopsis "A daemon for controlling APC UPSes") > > s/A // (as hinted by 'guix lint'). Same. > >> + (description "Apcupsd can be used for power mangement and controlli= ng most > > s/mangement/management/ Nice catch, fixed. > >> +of APC=E2=80=99s UPS models on Unix and Windows machines. Apcupsd work= s with most of >> +APC=E2=80=99s Smart-UPS models as well as most simple signalling models= such a Back-UPS, >> +and BackUPS-Office.") >> + (license license:gpl2))) > > I think it's actually license:gpl2+, according to > apcupsd-3.14.14/COPYING, which says: > > Each version is given a distinguishing version number. If the Program > specifies a version number of this License which applies to it and "any > later version", you have the option of following the terms and conditions > either of that version or of any later version published by the Free > Software Foundation. If the Program does not specify a version number of > this License, you may choose any version ever published by the Free Softw= are > Foundation. > > > In this case for most file the last sentence applies, some other > explicitly mention 'or any later version'. That's also supported by the > debian/copyright file. I do not think this is correct. When I check apcupsd-3.14.14/src/apcupsd.c file, I see this in its header: =2D-8<---------------cut here---------------start------------->8--- * Copyright (C) 1999-2005 Kern Sibbald * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General * Public License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1335, USA. =2D-8<---------------cut here---------------end--------------->8--- There is no mention of "any later version". Does that not make the combined work GPL-2.0-only, even if other files would be under GPL-2.0-or-later (I did no check whether they are)? I did not find debian/copyright file in the source code. > > Another thing found: the doc output doesn't build reproducibly, as > shown by: > > $ ./pre-inst-env guix build --no-grafts --check -K > guix build: error: derivation `/gnu/store/r62j72bd3an8k2fbmaiil5hma32syxd= y-apcupsd-3.14.14.drv' may not be deterministic: output `/gnu/store/bhwkrgk= qahgs5h8crcfyacvnwp7rj390-apcupsd-3.14.14-doc' differs from `/gnu/store/bhw= krgkqahgs5h8crcfyacvnwp7rj390-apcupsd-3.14.14-doc-check' > > Let's see why: > > $ diff -r /gnu/store/bhwkrgkqahgs5h8crcfyacvnwp7rj390-apcupsd-3.14.14-doc= {,-check} This is great, I did not know that it names the store item -check. Very useful, thank you. > diff -r > /gnu/store/bhwkrgkqahgs5h8crcfyacvnwp7rj390-apcupsd-3.14.14-doc/share/doc= /apcupsd-3.14.14/manual.html > /gnu/store/bhwkrgkqahgs5h8crcfyacvnwp7rj390-apcupsd-3.14.14-doc-check/sha= re/doc/apcupsd-3.14.14/manual.html > 376c376 > < <div class=3D"line">February 5, 2025 06:54:22</div> > --- >> <div class=3D"line">February 5, 2025 06:54:50</div> > > Ah, the classic date time stamp. You'll want to neuter it in the source > or in the built html file (with a preference for the former). Nice find, I have missed this. I have patched the source code of the manual to not embed the date and time, seems to work now. > > Could you please send a v2? Definitely, I will go through your review for the service file as well, and once I have all the answers (both here and there), will send v2. Once more thanks for the review, Tomas =2D-=20 There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJCBAEBCgAsFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmeo04sOHH5Ad29sZnNk ZW4uY3oACgkQL7/ufbZ/wakexA/9FXapBD7LTzTio9FuXl/LZfl0plqmid/KZEtn vGP4MBKSCb/IpQaYi1XQuXQEtBzoLMDprJraelLfMVck5I5v0Sqfsi5pZSSUHcHr ZzN2/flboVWyaol/Wee5zTFJUcAM8H2Pc61lNemwR8360Gm0qLIWXgIEiVw/k2I+ ViBbPXDo8zJJjTYT6L2GMFwVu2Rn6Ww9khd4U1mUy0IXxcu7rVgzoAJsA3He7Q1f TY7Sx4j5ggVZFcoTAc6VIYxRDHb78eiTCTObbPnSCODE2cCsmrLvuoW7qy+GhMKP ZkU/SLKoxx+H7xQ0Wp6QKPshUsAj8mKkK5LWtq0uT6LuLsY06HxxEihIynNSvwjc 8KA+zW7RzUqSEfne4V3xi6YXpyR396A7QmkT44Vy5Knd1zKaK2TMtJw38gYzVR/Y ACLmO0MylPthoHQgyKsdWBQT4Ynmstetw5jAbLGgqvxMhW9Otwhzo4auSbX0+qXI +EeXCQN8IzEIFWUFcKDm/+QqHyPtTDMcg/FjjYlbH16bJQzT0YX2pWWUt7xuyLlD FtSsvw80F4mdCaN0upKWRasFoqLarqmwGc+TRfEBZST4CBQBOZ8g5WsI+0/dZuAV FpJ2wcmoUhNkzeFA3uSUfsNCNsIEE9SjhIgI+IB8HaBtWv7l+4uumMyt3DOw/fPf OZSCClI= =ft5W -----END PGP SIGNATURE----- --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: [bug#75528] [PATCH 1/2] gnu: Add apcupsd. Resent-From: Tomas Volf <~@wolfsden.cz> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Sun, 09 Feb 2025 16:27:01 +0000 Resent-Message-ID: <handler.75528.B75528.173911838721684 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 75528 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer <maxim.cournoyer@HIDDEN> Cc: 75528 <at> debbugs.gnu.org Received: via spool by 75528-submit <at> debbugs.gnu.org id=B75528.173911838721684 (code B ref 75528); Sun, 09 Feb 2025 16:27:01 +0000 Received: (at 75528) by debbugs.gnu.org; 9 Feb 2025 16:26:27 +0000 Received: from localhost ([127.0.0.1]:45951 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1thA8Z-0005df-Dk for submit <at> debbugs.gnu.org; Sun, 09 Feb 2025 11:26:27 -0500 Received: from wolfsden.cz ([37.205.8.62]:33404) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1thA8V-0005dP-Ej for 75528 <at> debbugs.gnu.org; Sun, 09 Feb 2025 11:26:25 -0500 Received: by wolfsden.cz (Postfix, from userid 104) id 5893932594C; Sun, 9 Feb 2025 16:26:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1739118381; bh=LKccF9PrVqbMZC4mAlqG8qKsUQDIwxD2MmFoOLebM4Q=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=OIzhWMJTxIDy8trqFm8/7e+n7tQtycsddEn0Bexs/qW1EsqzGkzOVacdPRy0ujHPr 7D6Py6PGb9G0UiTCHTKkdetTZ7IyND8+nAA4Zboge1pMezkQQjQGEZAn2iXAtyqMFz wUH76N4y12Oya+04FCUhR6RZ3w2aBqYN1lBXqcUlojw725iIAFch1kLyt0E2F2HbKj oeq25JgSAEA1g9Jn0htamBDggWK65rPh9WD6Eh2oECMHkq0l/i/5P9+6VmmFJRb+wo ULGOsIFnaBEDaCXlDHWnKwhz7+aPgUeKf43TXXlp2Zuru2pif9ie5JLoHerN4SPdhy 9fqV4tmvfbwYhRL9p/cm003hyse1vvNmYVHPqEK692v9E12yVuXmMlMnCNtp9q89XV /CwEkdeurXf0DCrpv0PXGPxNWg2o9cHgTVXHh44cUcFG2gGVkwcMf0JUM1Db6GKSMf zDa4Ij8PpjgO2Q0RlQjnTKG+bY+2E41mzEnK4qd0wk5NWEw7+rjFcPhqXM0OqmIkfH IeMwR92IMHwYeZPE6UDVWNxNOfR76NGDTgMYhgYGzT79g1YcCJPYnTxaDRuC4ERcXZ Z95gfVA6oxg3vuR/uUVrACIUN+Ct853FKpZFoE6rGMke/kmSdnHY9qofU1HcC+S+0m KKaMp+GmgSXj57pqYc3Uo5Ec= X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on wolfsden X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED, URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id 84E02324C70; Sun, 9 Feb 2025 16:26:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1739118380; bh=LKccF9PrVqbMZC4mAlqG8qKsUQDIwxD2MmFoOLebM4Q=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=AniDATDQlYhqMNsFe8cUh241ay00HmOIigp/i6hDmZtKILQhjR0OlvwHCDUvpayV8 u5XLDEawrcuYzOBXZJzYnCoJOmdi2PSX7gydZ4xQCUFb8PWqH2QnC1m7mtJZ5Xhyvz Q/kw3SJe4E2SOQhZ8jUrwyZi+wu0arNApG49DW7sH0x/Vm4SExlJ3EG8FtKqGoTi3a +wwbaa5DMhVTxKupvQjbT/9Sb+bIu8K2mLLqcsyBkd+oZqZ2dLUqhICPB5Uu56YF3K qxKUjah+b5PHN4exb96TKOzRNeJHzfQfyxAkrEm41fzhX/m+hA3uLmnizYq04tzPmf eq77VoOhUhOTPefwUyEyAFQHABP/hb/fmbVjrjAOfjMQyvvWSFZi7mpS7GVPAcB+7v Vjz15QYP3WtH7FsADOraDsyBg7ExCV6sO4iu+rE8DE40N9x95n0BYA0mN4Pp1qGno2 /2BVrPU0ilsIgdzhzrM4tZ4ohS7uo4Q0UfdpWplZUjPiKyKL6Wa6eCEhhHyu+28SBS oPozkG4s00hEbBfqwJWPgyP/qwESEGCKUcdEVPvj78jAAvtYMkmZyCfWEyUAMi7OoY /2mVLF+/bZsRPtZGQm5Lea40Vl73nlMU326BfvANRVCORH3+2RICOV6n9iE3ROpXlJ mGYoRdL5nj/ouNAvcKMYk6kM= From: Tomas Volf <~@wolfsden.cz> In-Reply-To: <87frks98fm.fsf@HIDDEN> (Maxim Cournoyer's message of "Wed, 05 Feb 2025 16:06:53 +0900") References: <cover.1736722765.git.~@wolfsden.cz> <51cba7679af5c4aa9cf0e6d70453e369ff0909d6.1736722765.git.~@wolfsden.cz> <87frks98fm.fsf@HIDDEN> Date: Sun, 09 Feb 2025 17:26:20 +0100 Message-ID: <87lduff5jn.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 0.7 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.3 (/) --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Maxim Cournoyer <maxim.cournoyer@HIDDEN> writes: > Hi, > > Tomas Volf <~@wolfsden.cz> writes: > >> --- /dev/null >> +++ b/gnu/packages/power.scm >> @@ -0,0 +1,125 @@ >> +;;; Copyright (C) 2025 Tomas Volf <~@wolfsden.cz> >> +;;; Copyright (C) 2023 Raven Hallsby <karl@HIDDEN> > > One last thing; I don't see Raven listed in a 'Co-authored-by:' git > trailer in the commit message; should they? Or otherwise mention > plainly this work was based on their previous work, made available > '$where'. I did not know about co-authored trailer. Should it be used even in situations where I just took a look at his version online without any active involvement? Currently I have modified the commit message to: =2D-8<---------------cut here---------------start------------->8--- gnu: Add apcupsd. Some parts were taken or inspired by the work of Raven Hallsby available here[0]. For that reason I have added his copyright as well (I asked for t= he permission). 0: https://raw.githubusercontent.com/KarlJoad/guix/9013b5ac3fadb48fad2e7ef1= fbfaa4848dcb922a/gnu/packages/power.scm * gnu/packages/power.scm (apcupsd): New variable. * gnu/local.mk (GNU_SYSTEM_MODULES): Register the new file. Change-Id: I0e4b2f50c8adf0f96d140e2be0f79e3740f4955c =2D-8<---------------cut here---------------end--------------->8--- Is that sufficient? Tomas =2D-=20 There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJCBAEBCgAsFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmeo1ywOHH5Ad29sZnNk ZW4uY3oACgkQL7/ufbZ/wakakQ/+Icqd2dgQ/CeDbt0YUQW5ZOoGvxusDcC37Cir RyMl6sw3w/G+g9Om9KVRHFAu6yDgrrukGpEuHXv3bD7YgwwYUkbiyUD26qeMFZt2 oj23ujzH/gPoyDJP01N2nuFDZx2x4c5E6K4K9Hx3Eoh8B3Ot5KKHhIngbaPAO9TH dnEmRXnUH5eHAzEOl7QoY8WpV6gn7TQuxHOQdhM/Fc4ypbgmgq2w+Z0cYJSBXe3V HDNeJhxKb06+KJvsRsOsMUM1pZdZo9SUCdPzjoxy0hk+mT5t39TTNFGzk88rcC7T 37VElKMiDb6SzqXiJ+Ijiltv0CfibcrbSOZQCrRI4MfIIxOn0K+xAfrwcEwTg1rI nqIc87aKQ5H9qsEzKKWPcCaXefbNoAb3c6J5XVml9LN8h1+/Uvh3HbwXKw/i/F+1 QDbmiTcjauP5Sa2uK88pNMqoQG5bGJuSu/xqKTKHVlu1tzQRF8URiKNnQ4eMuwM5 ns/NaRZTYnKQWZlCi1LxBwZHbqa+TSAziLixhpuc7VWIDTuZiMrzXuiM/jK7q1Ko kMNqBPPtvY1tNxl63d41hVR0Tx5lnCmT+uG0UQPNYpYQYRJO7MbkxXTDdPZfp0NT A/n1YWABfMkK35ALxF5E3JicQ707o4u5T77YQ4k+j1p/S4t8h6DR8qvPZr74Utbq SqKLf08= =po+1 -----END PGP SIGNATURE----- --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: [bug#75528] [PATCH 1/2] gnu: Add apcupsd. Resent-From: Maxim Cournoyer <maxim.cournoyer@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Thu, 13 Feb 2025 05:44:02 +0000 Resent-Message-ID: <handler.75528.B75528.17394254296789 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 75528 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Tomas Volf <~@wolfsden.cz> Cc: 75528 <at> debbugs.gnu.org Received: via spool by 75528-submit <at> debbugs.gnu.org id=B75528.17394254296789 (code B ref 75528); Thu, 13 Feb 2025 05:44:02 +0000 Received: (at 75528) by debbugs.gnu.org; 13 Feb 2025 05:43:49 +0000 Received: from localhost ([127.0.0.1]:39575 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tiS0r-0001lR-81 for submit <at> debbugs.gnu.org; Thu, 13 Feb 2025 00:43:49 -0500 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:58734) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <maxim.cournoyer@HIDDEN>) id 1tiS0o-0001l6-HJ for 75528 <at> debbugs.gnu.org; Thu, 13 Feb 2025 00:43:47 -0500 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2fa3e20952fso1040706a91.1 for <75528 <at> debbugs.gnu.org>; Wed, 12 Feb 2025 21:43:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739425420; x=1740030220; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Nrm0nqFSqzZ2s2xPTK2mgHsH7Zepe8RhOD0EkmAoAew=; b=UpJlbJpyEpvqnpmbavtUz3UcVNr3J/K2Ng5XGegew/acWmreTwQlMg1quJdjF6GStr 4YXsdHZO45a1FlXAPaw1hI4IwIzlXIrVo5RH+6rebVp9hfnLTkzgaLmJFU2ULNBAskAp Q+zbHEmxkC/pciodUBFlYh4hPrfRb0hyCqoCnrpYjw6Fx8uPSIKDjfOCJPN1+yZGc5pX RexvdQq6oMYleuvOYmMKDtIt+YSAusc6Xmhh7pshmQvyc42TPzcoJRGhukV8k2Vg+Qw+ NPxDjPf6fSpi2l0JUPeKuTfv3hsrKD2b0Or+YjJryi8BkczpF9mgS1bvHKvWStIv48+P gpVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739425420; x=1740030220; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Nrm0nqFSqzZ2s2xPTK2mgHsH7Zepe8RhOD0EkmAoAew=; b=B2lss4bbYSq8LJImgdyIegOdBRi03sN5h0dq/aYhiQVV3nA2lVCe01+QLfMuqNmqVC fPrSlF5+5eMxW4guNfT+CDQFvQ4LLfSqonW14bJjkdiiVmDOfuUPptGgWxRwqGHqMTAG 5OlTRWrk4n56KFNF687FFKOtgVjqgQ/9JglFYoMJM4Zq3WB17h9p0Buczj/FgM1NCaoa CgQqaq/QQ9D7LthDJGiEZMaNz7VP3XDA1TJyD7dLk5Aqfd9zYuI3p/2hjcsVF+w46Pat p3NgipPhRgxCBOnHQR+OLQuXXj/OMo2tHbTMxWyW4nm44uZuZiFk0GIDahrAYMtOPq/0 eibQ== X-Gm-Message-State: AOJu0YyeLmFyy6JTjjgqyd9efJfuWUeKX0tkJynj9qWRvyg+BMQFOFuM XaoweXSGmanmh7zYODZ1aa/Nh/cnVeEigA8VGSiD5L4NdKe6fIobT8XpK4Qe X-Gm-Gg: ASbGncsCYLlM5UXK7EEGyP2WHPoYwnh9SoqtkyB4j3yl+qUgt4Q9eTqvyj08um5hER8 eXf4G+0ynkKKo4TQDNncWpKRACZTyK+dW8gugMi9Z+E0slm16t1f7BJGZOtWnSA2vyxqM80ioXq RDj+l7sMrF9H5kjRtdb09OIkGLdB5ixk9qQVPgZH2GXxBMM8wfTcxjoO7bCS99SY+s7nlDxOu2I xCLWACW4NdN4WvMf0uBQUad8FDSf80SVLTZFijaPfHbOrAKLxVjogUf3CMmzXN74br24N+lx7yW 9ipKpZzCyeew X-Google-Smtp-Source: AGHT+IEnFG8yYEQr6pPXXwa4isEqc/zXog/fNIeWNmS6/Kw8Q/PKPYSoWekXbwRXgLB46f1wpwmPXQ== X-Received: by 2002:a05:6a00:98b:b0:732:1bad:e245 with SMTP id d2e1a72fcca58-7322c37ea39mr8013084b3a.7.1739425419676; Wed, 12 Feb 2025 21:43:39 -0800 (PST) Received: from terra ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73242761694sm411698b3a.125.2025.02.12.21.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Feb 2025 21:43:38 -0800 (PST) From: Maxim Cournoyer <maxim.cournoyer@HIDDEN> In-Reply-To: <87lduff5jn.fsf@HIDDEN> (Tomas Volf's message of "Sun, 09 Feb 2025 17:26:20 +0100") References: <cover.1736722765.git.~@wolfsden.cz> <51cba7679af5c4aa9cf0e6d70453e369ff0909d6.1736722765.git.~@wolfsden.cz> <87frks98fm.fsf@HIDDEN> <87lduff5jn.fsf@HIDDEN> Date: Thu, 13 Feb 2025 14:43:27 +0900 Message-ID: <87y0yal7r4.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.7 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.3 (/) Hi Tomas, Tomas Volf <~@wolfsden.cz> writes: > Hi, > > Maxim Cournoyer <maxim.cournoyer@HIDDEN> writes: > >> Hi, >> >> Tomas Volf <~@wolfsden.cz> writes: >> >>> --- /dev/null >>> +++ b/gnu/packages/power.scm >>> @@ -0,0 +1,125 @@ >>> +;;; Copyright (C) 2025 Tomas Volf <~@wolfsden.cz> >>> +;;; Copyright (C) 2023 Raven Hallsby <karl@HIDDEN> >> >> One last thing; I don't see Raven listed in a 'Co-authored-by:' git >> trailer in the commit message; should they? Or otherwise mention >> plainly this work was based on their previous work, made available >> '$where'. > > I did not know about co-authored trailer. Should it be used even in > situations where I just took a look at his version online without any > active involvement? Currently I have modified the commit message to: I believe if you reused enough of the code to make it necessary to add their name to the copyright notice, then a Co-authored-by git trailer would make sense (whether they were actively involved in your version or not). > gnu: Add apcupsd. > > Some parts were taken or inspired by the work of Raven Hallsby available > here[0]. For that reason I have added his copyright as well (I asked for the > permission). > > 0: https://raw.githubusercontent.com/KarlJoad/guix/9013b5ac3fadb48fad2e7ef1fbfaa4848dcb922a/gnu/packages/power.scm > > * gnu/packages/power.scm (apcupsd): New variable. > * gnu/local.mk (GNU_SYSTEM_MODULES): Register the new file. > > Change-Id: I0e4b2f50c8adf0f96d140e2be0f79e3740f4955c > > Is that sufficient? Co-authored-by is not mandatory, but I see it as a nice etiquette to have, similar to how it's important to preserve the proper commit authorship information, for due credits. -- Thanks, Maxim
X-Loop: help-debbugs@HIDDEN Subject: [bug#75528] [PATCH 1/2] gnu: Add apcupsd. Resent-From: Maxim Cournoyer <maxim.cournoyer@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Thu, 13 Feb 2025 06:02:02 +0000 Resent-Message-ID: <handler.75528.B75528.173942649510347 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 75528 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Tomas Volf <~@wolfsden.cz> Cc: 75528 <at> debbugs.gnu.org Received: via spool by 75528-submit <at> debbugs.gnu.org id=B75528.173942649510347 (code B ref 75528); Thu, 13 Feb 2025 06:02:02 +0000 Received: (at 75528) by debbugs.gnu.org; 13 Feb 2025 06:01:35 +0000 Received: from localhost ([127.0.0.1]:39651 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tiSI3-0002go-1C for submit <at> debbugs.gnu.org; Thu, 13 Feb 2025 01:01:35 -0500 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:49280) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <maxim.cournoyer@HIDDEN>) id 1tiSI0-0002gU-Ia for 75528 <at> debbugs.gnu.org; Thu, 13 Feb 2025 01:01:33 -0500 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-2fbfa8c73a6so1045453a91.2 for <75528 <at> debbugs.gnu.org>; Wed, 12 Feb 2025 22:01:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739426485; x=1740031285; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=35DuGeHP+2fVSq2DvNHpu3BA5r/8Kyffx1hiuxkVkEc=; b=Ha0pl78bnRWJjl5Wtyj1mrtS2MtffywydirR9SpgwunebELP8MZm51bA4uKix6K0q/ wZe1CEpuzCLoY2snbAW8ltGD/71khP4r77ZdX66n45FgiDk/Rv5RHfpUlEz5hbHv9uSG wavBFOKC5jxqpOQ7LP39OO68Lfq/QfxbRHFe7colaMI0VxGCFqOPC8vLa3XnBMM8j6hH BWntl9bLnwC14oI6y1OT+h9zXEjxpNF8KiU6M8PzMzFuFTOvnKzPH8SVdk/cwxPhmEMo lKZJUwVUwh66jgIBd8zJhXCpo9PIT+QBz6q6n4e9ieLMNzON+llOcBPeWJ8dKdkMtv+8 ZiWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739426485; x=1740031285; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=35DuGeHP+2fVSq2DvNHpu3BA5r/8Kyffx1hiuxkVkEc=; b=BDpSaaaKShjnvQtviN7cetWpc33J+6ySQSZZgIjWEZ5SS6xdArUocTkOCQ7Zcz36XF tvyfBO7g0QKY2JOiiBMcvXWvGREKHLyg3ZCJb0TuYRBZjtlVDQnk98DoiQfCeMCfaqYZ VZJI7jsn+SQeO8KloVlQTI43Bq/7r3eZq1BHHLQnCAHFAHd50M2CfYHOyldxJC+RxhYI f4Gvw86syEIdHCXBUJfzTq2kBKdFOQmUeohXvHJ7T/Q4Q03c3NdyA6zQg0XOUtWdShHh Wgo06lhXqGAZwFo3lRWAenT4T6OPtj6OS6ifsOGkt528gpgUv+iDLdNN0peyDI2U+n94 LaJA== X-Gm-Message-State: AOJu0Yz9RqYOwQydtctG9vVGsbwogR51VRvDr7PxkT49vz5efWiukzvm 5cW37pmUWPKX31BXU6He0Z8ygVTYjkqsZ68dCBP4M4//2vwVz4uPOPV2QXTc X-Gm-Gg: ASbGncureqKkRmjiDIDD/njvnOQA2BQ65U85s0rmtuVOJP0ZrzwN552X4t4GFHOX983 9pnOBjwTJzsHjaDtIylJjune/gTt/LVae6bfjFZUk4W5jV5Rt2DYu1wWdfIlFHjWlIgxW5lfFVf TDlg3CvyS4vpUGI0cUGESPRtmmiwnHwpcTy8HNI6akEHeKzHEtgpTr7u0H4dUblpTN5FfANgrTB 807DP3so/s4z+aoqZcN3w/I/nHBWg3Jm3ng24Hfp+dYqtyoHGB9Kdm8pU4l2ztNxTFot/wLlUui EBTFMOTs9kp2 X-Google-Smtp-Source: AGHT+IHUpbWOlageiMPzyj8+GJzUV5i5jl+KXiHRYiUxBuDLzrL17f+jAa6Jj9OIE6EKcgAlyvcwag== X-Received: by 2002:a17:90b:2712:b0:2ea:bf1c:1e3a with SMTP id 98e67ed59e1d1-2fbf5bec6bbmr11731289a91.12.1739426485261; Wed, 12 Feb 2025 22:01:25 -0800 (PST) Received: from terra ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fbf98f0facsm2479394a91.23.2025.02.12.22.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Feb 2025 22:01:24 -0800 (PST) From: Maxim Cournoyer <maxim.cournoyer@HIDDEN> In-Reply-To: <87pljrf69g.fsf@HIDDEN> (Tomas Volf's message of "Sun, 09 Feb 2025 17:10:51 +0100") References: <cover.1736722765.git.~@wolfsden.cz> <51cba7679af5c4aa9cf0e6d70453e369ff0909d6.1736722765.git.~@wolfsden.cz> <87jza498sp.fsf@HIDDEN> <87pljrf69g.fsf@HIDDEN> Date: Thu, 13 Feb 2025 15:01:12 +0900 Message-ID: <87tt8yl6xj.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hi Tomas, Tomas Volf <~@wolfsden.cz> writes: [...] >> I think /var/run is deprecated in favor of just /run, so we should >> configure the package to use this, I think. > > It seems pretty much all programs on my system are using /var/run, > including Shepherd. Only programs that store information in /run seem > to be elogind and dbus. > > Is deprecation of /var/run listed somewhere in the manual? I am > surprised Shepherd (since it is actively maintained and core component) > is still in /var/run. I looked and found 42 references to /var/run, but > none with the deprecation notice. > > Assuming you will insist on moving it to /run, is there some structure > to follow in that directory? Or just s~/var/run~/run~? What about /var > and /var/log? Should those be moved somewhere as well? > >> >>> + (string-append "ac_cv_path_SHUTDOWN=/nope") >>> + (string-append "ac_cv_path_APCUPSD_MAIL=/nope") >>> + ;; While `wall' is not expanded anywhere, it still is searched for. >>> + (string-append "ac_cv_path_WALL=/nope") >> >> I'm not sure if this package is actively developed, but that last issue >> should ideally be reported (then cross-referenced here). > > I did not found a way to report a bug. Nothing is listed in the manual, > and their apcupsd-users mailing list requires JavaScript to sign up (and > does not tell me the email address otherwise). > > I did try to blindly send an email, will see if it will be accepted > without being subscribed. If that happens, I will add the link here. OK, thank you. >> >>> + ;; Enable additional drivers. >>> + "--enable-test" >> >> Is '--enable-test' useful? What does it do? > > According to the manual > > This turns on a test driver that is used only for debugging. > > > Since there does not seem to be any harm in having it on, I enabled it, > since Guix seems to aim for feature complete packages (I assume that is > the reason for everything being so large). But I have no use for it, so > I can turn it off if you would prefer. For this kind of very edge case that is not enabled by default, I'd leave it off. Our maximalist take on things doesn't including switching on every non-default option, but if extra dependencies are automatically picked as part of the configure script, then we would typically add them, unless they grow the 'guix size' of the package unreasonably (like adding libreoffice to emacs-org-mode because it has support for it :-)). It's one of the reason. Other reasons are references kept erroneously, static libraries, large documentation, wrappers keeping references to native inputs that shouldn't be captured, etc. There's a lot of work to do to reduce the size of the distribution :-). [...] >>> + (add-before 'configure 'touch-txt-docs >>> + (lambda _ >>> + (for-each (lambda (f) >>> + (call-with-output-file f close-port)) >>> + '("doc/apcupsd.man.txt" >>> + "doc/apcaccess.man.txt" >>> + "doc/apctest.man.txt" >>> + "doc/apccontrol.man.txt" >>> + "doc/apcupsd.conf.man.txt")))) >> >> I think I'd rather depend on these than introduce hacks like below. > > The "hacks" *below* would still be required. The HTML manual is not > built nor installed by default, and there is no target to invoke to > install them. So both 'build-manual and 'move-doc phases would still be > required. > > We could get rid of the "hack" *above* ('touch-txt-docs), true. It is > worth those two additional inputs? Yes, I meant above, sorry. I don't see mandoc and util-linux as large dependencies enough to justify working around these, especially if they are only used at build time. And, the would actually be useful when working on the source of acupsd in a 'guix shell -D acupsd' environment, so I'd just add them. [...] >> >>> + (add-after 'install 'remove-etc-apcupsd >>> + (lambda _ >>> + (delete-file-recursively (string-append #$output "/etc/apcupsd"))))))) >> >> Break this long line so it fits under 80 columns (our code style >> guideline). > > I thought (well, still do), that going 4 characters over the limit was > worth the increase in readability. Nevertheless, I have split it into > two lines. Thanks. In some cases where it really hurts readability, it may be fine (it's a guideline after all), but the usual business of simply moving one parentheses pair down is not one of these :-). [...] > I do not think this is correct. When I check > apcupsd-3.14.14/src/apcupsd.c file, I see this in its header: [...] > There is no mention of "any later version". Does that not make the > combined work GPL-2.0-only, even if other files would be under > GPL-2.0-or-later (I did no check whether they are)? You are right, and yes the combined work would be GPLv2 only then. > I did not find debian/copyright file in the source code. There's one at least in https://sourceforge.net/projects/apcupsd/files/apcupsd%20-%20Stable/3.14.14/apcupsd-3.14.14.tar.gz/download [...] >> Could you please send a v2? > > Definitely, I will go through your review for the service file as well, > and once I have all the answers (both here and there), will send v2. I haven't seen v2 yet, I guess you are still working out the service part? -- Thanks, Maxim
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.