From patchwork Mon Dec 25 23:59:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "ashish.is--- via Guix-patches\" via" X-Patchwork-Id: 58072 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8109427BBE2; Tue, 26 Dec 2023 00:01:14 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HTML_MESSAGE,MAILING_LIST_MULTI,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AAEC327BBE9 for ; Tue, 26 Dec 2023 00:01:10 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rHusU-0001uU-D4; Mon, 25 Dec 2023 19:00:58 -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 ) id 1rHusR-0001u4-JQ for guix-patches@gnu.org; Mon, 25 Dec 2023 19:00:56 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rHusR-00028J-7U for guix-patches@gnu.org; Mon, 25 Dec 2023 19:00:55 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rHusX-00075U-Ik for guix-patches@gnu.org; Mon, 25 Dec 2023 19:01:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68012] [PATCH] thinkfan-service-type: Place config-file in /etc/thinkfan.conf if file-like References: <29b6707c8c4cdf1808edc79813215578@disroot.org> In-Reply-To: <29b6707c8c4cdf1808edc79813215578@disroot.org> Resent-From: lgcoelho@disroot.org Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 26 Dec 2023 00:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68012 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68012@debbugs.gnu.org Received: via spool by 68012-submit@debbugs.gnu.org id=B68012.170354880920318 (code B ref 68012); Tue, 26 Dec 2023 00:01:01 +0000 Received: (at 68012) by debbugs.gnu.org; 26 Dec 2023 00:00:09 +0000 Received: from localhost ([127.0.0.1]:55546 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rHurg-0005GY-HX for submit@debbugs.gnu.org; Mon, 25 Dec 2023 19:00:09 -0500 Received: from layka.disroot.org ([178.21.23.139]:57956) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rHurc-0004s5-OA for 68012@debbugs.gnu.org; Mon, 25 Dec 2023 19:00:06 -0500 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 6057B41A36 for <68012@debbugs.gnu.org>; Tue, 26 Dec 2023 00:59:55 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ML5YWLMKwsLG for <68012@debbugs.gnu.org>; Tue, 26 Dec 2023 00:59:54 +0100 (CET) MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1703548794; bh=G0a+0blGPujdixKzicDKfCVf/1vUkvH4GQFPT+Lj7uM=; h=Date:From:To:Subject; b=IX0kSqBA/xWhoo2VoSruBxF5j1CRmzEnXTnZ6IV3X2TLLoeCJcsWIDdqkUa2eLHmU DSUasXoELqUOaxVmEL9PQi+6Dd1pGed0sMBnUUILp1+wFh7LcTecCaB35zjIRIx6/0 qg7Jj3ztS/+T+WXHsvssospHMW69+F5KI1/zzzHqqQYdVElv/x+C6PzY5EuSoGiVsU atIusQ5xv6pYdZyGPh8dPkbQvuHFPLXbVu8daL4zYahKRkKwNKk48vrhp4KlWie9H8 kaGQ72t+gYJ1BWtzIBwckjhTCpIW5hRnxmBesnYwvIKmq0Ib2x9Izvs+8aaD7Yw9if JP2KErNTNGB8g== Date: Mon, 25 Dec 2023 23:59:54 +0000 Message-ID: <1e749af5b479cbc13f70c2ce64121682@disroot.org> X-Sender: lgcoelho@disroot.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: lgcoelho@disroot.org X-ACL-Warn: , lgcoelho--- via Guix-patches X-Patchwork-Original-From: lgcoelho--- via Guix-patches via From: "ashish.is--- via Guix-patches\" via" Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches From 0160f08bb315ee297b0ad8b861f9e3b5bd7eedfb Mon Sep 17 00:00:00 2001 From: Luis Guilherme Coelho Date: Mon, 25 Dec 2023 20:48:35 -0300 Subject: [PATCH 2/2] thinkfan-service-type: Place config-file in /etc/thinkfan.conf if file-like --- gnu/services/pm.scm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm index baded5c43e..2d02476d20 100644 --- a/gnu/services/pm.scm +++ b/gnu/services/pm.scm @@ -470,12 +470,16 @@ (define thermald-service-type (description "Run thermald, a CPU frequency scaling service that helps prevent overheating."))) +(define (string-or-file-like? x) + (or (string? x) + (file-like? x))) + (define-configuration/no-serialization thinkfan-configuration (pid-file (string "/var/run/thinkfan.pid") "Where to store the PID file.") (config-file - (string "/etc/thinkfan.conf") + (string-or-file-like "/etc/thinkfan.conf") "Configuration file to use.") (log-file (string "/var/log/thinkfan.log") @@ -511,15 +515,25 @@ (define thinkfan-modprobe-config (define (thinkfan-modprobe-etc-service config) `(("modprobe.d/thinkfan.conf" ,thinkfan-modprobe-config))) +(define thinkfan-activation + (match-record-lambda + (config-file) + (when (file-like? config-file) + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (copy-file #$config-file "/etc/thinkfan.conf")))))) + (define thinkfan-service-type (service-type (name 'thinkfan) (extensions (list (service-extension shepherd-root-service-type thinkfan-shepherd-service) + (service-extension activation-service-type + thinkfan-activation) (service-extension etc-service-type thinkfan-modprobe-etc-service))) (default-value (thinkfan-configuration)) (description "Adjust fan level according to configured temperature limits."))) - -- 2.41.0