summaryrefslogtreecommitdiff
path: root/upstream/services
diff options
context:
space:
mode:
Diffstat (limited to 'upstream/services')
-rw-r--r--upstream/services/nbfc.scm65
1 files changed, 65 insertions, 0 deletions
diff --git a/upstream/services/nbfc.scm b/upstream/services/nbfc.scm
new file mode 100644
index 0000000..4b0b646
--- /dev/null
+++ b/upstream/services/nbfc.scm
@@ -0,0 +1,65 @@
+(define-module (upstream services nbfc)
+ ;; #:use-module (gnu packages linux)
+ #:use-module (gnu services)
+ #:use-module (gnu services shepherd)
+ #:use-module (guix build utils)
+ #:use-module (guix gexp)
+ #:use-module (guix records)
+ #:use-module (upstream packages nbfc)
+ #:export (nbfc-configuration))
+
+(define-record-type* <nbfc-configuration>
+ nbfc-configuration
+ make-nbfc-configuration
+ nbfc-configuration?
+ (package get-nbfc-configuration-package
+ (default nbfc-linux))
+ (model get-nbfc-configuration-model
+ (default "undefined")))
+
+(define (nbfc-etc-extension configuration-record)
+ (let* ((model (get-nbfc-configuration-model configuration-record))
+
+ (nbfc-configuration-file (mixed-text-file "nbfc.json-stored"
+ "{\"SelectedConfigId\": \""
+ model
+ "\"}\n")))
+ (list `("nbfc.json" ,nbfc-configuration-file))))
+
+(define nbfc-profile-extension
+ (lambda (configuration-record)
+ (list (get-nbfc-configuration-package configuration-record))))
+
+(define (nbfc-shepherd-extension configuration-record)
+ (let* ((profile (get-nbfc-configuration-package configuration-record))
+
+ (service-executable (file-append profile
+ "/bin/nbfc_service"))
+
+ (start-command #~ (list #$ service-executable
+ "--config-file"
+ "/etc/nbfc.json"))
+
+ (start-process #~ (make-forkexec-constructor #$ start-command))
+ (symbols (list 'nbfc))
+
+ (default-service (shepherd-service (provision symbols)
+ (start start-process))))
+ (list default-service)))
+
+(define-public nbfc-service-type
+ (let* ((nbfc-etc-extension* (service-extension etc-service-type
+ nbfc-etc-extension))
+ (nbfc-profile-extension* (service-extension profile-service-type
+ nbfc-profile-extension))
+ (nbfc-shepherd-extension* (service-extension shepherd-root-service-type
+ nbfc-shepherd-extension))
+
+ (description "C port of Stefan Hirschmann's NoteBook FanControl")
+ (extensions (list nbfc-etc-extension*
+ nbfc-profile-extension*
+ nbfc-shepherd-extension*)))
+ (service-type (name 'nbfc)
+ (extensions extensions)
+ (description description)
+ (default-value (nbfc-configuration)))))