diff mbox series

[bug#45105] gnu: Add mbpfan service

Message ID 87a6ups6pd.fsf@posteo.net
State New
Headers show
Series [bug#45105] gnu: Add mbpfan service | expand

Checks

Context Check Description
cbaines/submitting builds success
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Niklas Eklund Dec. 7, 2020, 8:26 p.m. UTC
Hi,

this is a patch that adds the service for mbpfan. The mbpfan package
that exists in guix requires sudo rights to run. So I have been using
this service for a while and thought it was a good time to try to merge
it upstream :)

Cheers

Comments

Mathieu Othacehe Jan. 6, 2021, 10:11 a.m. UTC | #1
Hello Niklas,

> * gnu/services/mbpfan.scm (mbpfan service): New variable.

Thanks for your contribution and sorry for the late review.

> +                       #$@(if verbose?
> +                            '("-v") ; verbose logging
> +                            '()))
> +                 #:log-file #$log-file))

The indentation is off here.

> +    (list (service-extension shepherd-root-service-type mbpfan-shepherd-service)))

You should wrap this line to stay under the 78 cols limit.

You also need to add this file to 'gnu/local.mk'. It would also be nice
to write some documentation, probably under "Power management services".

Could you please send an updated patch?

Thanks,

Mathieu
diff mbox series

Patch

From 9773af047fc3ddb337a2d9ac346a1655d2bc11ee Mon Sep 17 00:00:00 2001
From: Niklas Eklund <niklas.eklund@posteo.net>
Date: Mon, 7 Dec 2020 20:53:07 +0100
Subject: [PATCH] gnu: Add mbpfan service.

* gnu/services/mbpfan.scm (mbpfan service): New variable.
---
 gnu/services/mbpfan.scm | 73 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 gnu/services/mbpfan.scm

diff --git a/gnu/services/mbpfan.scm b/gnu/services/mbpfan.scm
new file mode 100644
index 0000000000..425da6baab
--- /dev/null
+++ b/gnu/services/mbpfan.scm
@@ -0,0 +1,73 @@ 
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2020 Niklas Eklund <niklas.eklund@posteo.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix 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 GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services mbpfan)
+  #:use-module (gnu packages linux)
+  #:use-module (gnu services)
+  #:use-module (gnu services base)
+  #:use-module (gnu services shepherd)
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 format)
+  #:use-module (guix modules)
+  #:export (mbpfan-service-type
+
+            mbpfan-configuration
+            mbpfan-configuration?))
+
+;;; Commentary:
+;;;
+;;; This module provides a service definition for the mbpfan.
+;;;
+;;; Code:
+
+(define-record-type* <mbpfan-configuration>
+  mbpfan-configuration make-mbpfan-configuration
+  mbpfan-configuration?
+  (log-file mbpfan-configuration-log-file ;string
+            (default "/var/log/mbpfan.log"))
+  (verbose? mbpfan-configuration-verbose? (default #f)))
+
+(define mbpfan-shepherd-service
+  (match-lambda
+    (($ <mbpfan-configuration> log-file verbose?)
+     (list
+      (shepherd-service
+       (documentation "Run the mbpfan daemon.")
+       (provision '(mbpfan))
+       (requirement '(syslogd))
+       (start #~(make-forkexec-constructor
+                 (list #$(file-append mbpfan "/sbin/mbpfan")
+                       "-f"
+                       #$@(if verbose?
+                            '("-v") ; verbose logging
+                            '()))
+                 #:log-file #$log-file))
+       (stop #~(make-kill-destructor)))))))
+
+(define mbpfan-service-type
+  (service-type
+   (name 'mbpfan)
+   (extensions
+    (list (service-extension shepherd-root-service-type mbpfan-shepherd-service)))
+   (description
+    "Run the MacBook/Macbook Pro fan daemon.")
+   (default-value (mbpfan-configuration))))
+
+;;; mbpfan.scm ends here
-- 
2.29.2