Subject: [PATCH v2 4/5] DRAFT gnu: home: services: Add home-kodi-service-type.

From: "Jan (janneke) Nieuwenhuizen" <[email-masked]>
Date: Thu, 16 Feb 2023 16:53:54 +0100

* gnu/home/services/shepherd-xyz.scm
(<home-kodi-configuration>): New type.
(home-kodi-services): New procedure.
(home-kodi-service-type): New variable.
---
 gnu/home/services/shepherd-xyz.scm | 41 ++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/gnu/home/services/shepherd-xyz.scm b/gnu/home/services/shepherd-xyz.scm
index 856a5e7246..f5bedf60c7 100644
--- a/gnu/home/services/shepherd-xyz.scm
+++ b/gnu/home/services/shepherd-xyz.scm
@@ -25,6 +25,7 @@ (define-module (gnu home services shepherd-xyz)
 
   #:use-module (gnu home services)
   #:use-module (gnu home services shepherd)
+  #:use-module (gnu packages kodi)
   #:use-module (gnu packages messaging)
   #:use-module (gnu packages ssh)
   #:use-module (gnu packages version-control)
@@ -35,6 +36,8 @@ (define-module (gnu home services shepherd-xyz)
 
   #:export (home-git-daemon-configuration
             home-git-daemon-service-type
+            home-kodi-configuration
+            home-kodi-service-type
             home-ssh-agent-configuration
             home-ssh-agent-service-type
             home-znc-configuration
@@ -136,6 +139,44 @@ (define home-git-daemon-service-type
    (description
     "Install and configure the git-daemon as a shepherd service.")))
 
+
+;;;
+;;; Kodi.
+;;;
+(define-record-type* <home-kodi-configuration>
+  home-kodi-configuration make-home-kodi-configuration
+  home-kodi-configuration?
+  (kodi          home-kodi-kodi          ;file-like
+                 (default kodi))
+  (extra-options home-kodi-extra-options ;list of string
+                 (default '())))
+
+(define (home-kodi-services config)
+  "Return a <shepherd-service> for kodi with CONFIG."
+  (match config
+    (($ <home-kodi-configuration> kodi extra-options)
+     (let* ((kodi (file-append kodi "/bin/kodi"))
+            (command `(kodi
+                       "-fs"
+                       ,@extra-options))
+            (log-file (string-append %user-log-dir "/kodi.log")))
+       (list (shepherd-service
+              (documentation "Run the kodi media center.")
+              (provision '(kodi))
+              (start #~(make-forkexec-constructor '#$command
+                                                  #:log-file #$log-file))
+              (stop #~(make-kill-destructor))))))))
+
+(define home-kodi-service-type
+  (service-type
+   (name 'home-kodi)
+   (default-value (home-kodi-configuration))
+   (extensions
+    (list (service-extension home-shepherd-service-type
+                             home-kodi-services)))
+   (description
+    "Install and configure kodi as a shepherd service.")))
+
 
 ;;;
 ;;; Ssh-agent.
-- 
2.38.1