diff mbox series

[bug#68012] thinkfan-service-type: Place config-file in /etc/thinkfan.conf if file-like

Message ID 1e749af5b479cbc13f70c2ce64121682@disroot.org
State New
Headers show
Series [bug#68012] thinkfan-service-type: Place config-file in /etc/thinkfan.conf if file-like | expand

Commit Message

vasilii.smirnov--- via Guix-patches" via Dec. 25, 2023, 11:59 p.m. UTC

Comments

Josselin Poiret Jan. 13, 2024, 4:30 p.m. UTC | #1
lgcoelho--- via Guix-patches via <guix-patches@gnu.org> writes:

> +(define thinkfan-activation
> +  (match-record-lambda <thinkfan-configuration>
> +    (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"))))))
> +

This is not needed as you already specify the config file to use to
thinkfan with the -c option.
diff mbox series

Patch

From 0160f08bb315ee297b0ad8b861f9e3b5bd7eedfb Mon Sep 17 00:00:00 2001
From: Luis Guilherme Coelho <lgcoelho@disroot.org>
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 <thinkfan-configuration>
+    (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