From 869528b29580af68eebea64fe5911602053da7b9 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Mon, 18 Nov 2024 21:41:36 -0800 Subject: [PATCH] Add cbatticon service --- oni/home/config/data.scm | 5 +++- oni/home/services/admin.scm | 55 +++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 oni/home/services/admin.scm diff --git a/oni/home/config/data.scm b/oni/home/config/data.scm index 79bd5f0..dc5c3a9 100644 --- a/oni/home/config/data.scm +++ b/oni/home/config/data.scm @@ -15,6 +15,8 @@ #:use-module (gnu services) #:use-module (guix gexp) #:use-module (oni home config common) + #:use-module ((oni home services admin) + #:select (home-cbatticon-service-type)) #:use-module (oni home services cmst) #:use-module (oni home services dunst) #:use-module ((oni home services emacs) @@ -298,4 +300,5 @@ (service home-emacs-golden-ratio-service-type) (service home-emacs-pinentry-service-type) - (service home-xss-lock-service-type)))) + (service home-xss-lock-service-type) + (service home-cbatticon-service-type)))) diff --git a/oni/home/services/admin.scm b/oni/home/services/admin.scm new file mode 100644 index 0000000..4198937 --- /dev/null +++ b/oni/home/services/admin.scm @@ -0,0 +1,55 @@ +(define-module (oni home services admin) + #:use-module ((gnu home services) + #:select (service-type + service-extension + home-profile-service-type)) + #:use-module ((gnu home services shepherd) + #:select (home-shepherd-service-type + shepherd-service)) + #:use-module ((gnu packages admin) + #:select (cbatticon)) + #:use-module ((gnu services configuration) + #:select (serialize-package + define-configuration)) + #:use-module ((guix gexp) + #:select (gexp + file-append)) + #:use-module ((guix packages) + #:select (package?)) + + #:export (home-cbatticon-configuration + home-cbatticon-service-type)) + +(define-configuration home-cbatticon-configuration + (package + (package cbatticon) + "Package to use for setting cbatticon")) + +(define (add-cbatticon-packages config) + (list (home-cbatticon-configuration-package config))) + +(define (home-cbatticon-shepherd-service config) + (list + (shepherd-service + (documentation "Start cbatticon") + (provision '(cbatticon)) + (auto-start? #t) + (start + #~(make-forkexec-constructor + (list #$(file-append (home-cbatticon-configuration-package config) "/bin/cbatticon")) + #:log-file (format #f "~a/.local/var/log/cbatticon.log" (getenv "HOME")))) + (stop #~(make-kill-destructor))))) + +(define home-cbatticon-service-type + (service-type + (name 'home-cbatticon) + (extensions + (list (service-extension + home-profile-service-type + add-cbatticon-packages) + (service-extension + home-shepherd-service-type + home-cbatticon-shepherd-service))) + (compose identity) + (default-value (home-cbatticon-configuration)) + (description "Install and configure cbatticon.")))