diff mbox series

[bug#61483,v2,4/5] DRAFT gnu: home: services: Add home-kodi-service-type.

Message ID 20230216155355.11106-4-janneke@gnu.org
State New
Headers show
Series [bug#61483,v2,1/5] DRAFT gnu: home: services: Add home-git-daemon-service-type. | expand

Commit Message

Janneke Nieuwenhuizen Feb. 16, 2023, 3:53 p.m. UTC
* 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(+)

Comments

Ludovic Courtès March 4, 2023, 5:10 p.m. UTC | #1
"Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:

> * gnu/home/services/shepherd-xyz.scm
> (<home-kodi-configuration>): New type.
> (home-kodi-services): New procedure.
> (home-kodi-service-type): New variable.

Rather ‘media.scm’?

> +(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.")))

Maybe something like: “Install and configure the Kodi media center so
that it runs as a Shepherd service.”

Likewise: this + manual entry and we’re all set IMO!
Janneke Nieuwenhuizen March 5, 2023, 6:11 p.m. UTC | #2
Ludovic Courtès writes:

> "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:
>
>> * gnu/home/services/shepherd-xyz.scm
>> (<home-kodi-configuration>): New type.
>> (home-kodi-services): New procedure.
>> (home-kodi-service-type): New variable.
>
> Rather ‘media.scm’?

Check.

>> +   (description
>> +    "Install and configure kodi as a shepherd service.")))
>
> Maybe something like: “Install and configure the Kodi media center so
> that it runs as a Shepherd service.”

Done.
diff mbox series

Patch

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.