| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 |
|
| 20 | (define-module (gnu home services media)
|
| 21 | #:use-module (srfi srfi-26)
|
| 22 | #:use-module (gnu home services)
|
| 23 | #:use-module (gnu home services desktop)
|
| 24 | #:use-module (gnu home services shepherd)
|
| 25 | #:use-module (gnu packages kodi)
|
| 26 | #:use-module (gnu packages video)
|
| 27 | #:use-module (gnu services configuration)
|
| 28 | #:use-module (gnu services shepherd)
|
| 29 | #:use-module (guix packages)
|
| 30 | #:use-module (guix records)
|
| 31 | #:use-module (guix gexp)
|
| 32 | #:export (home-kodi-configuration
|
| 33 | home-kodi-service-type
|
| 34 |
|
| 35 | home-jellyfin-mpv-shim-configuration
|
| 36 | home-jellyfin-mpv-shim-service-type))
|
| 37 |
|
| 38 |
|
| 39 | |
| 40 | |
| 41 | |
| 42 |
|
| 43 | (define-record-type* <home-kodi-configuration>
|
| 44 | home-kodi-configuration make-home-kodi-configuration
|
| 45 | home-kodi-configuration?
|
| 46 | (kodi home-kodi-kodi |
| 47 | (default kodi))
|
| 48 | (extra-options home-kodi-extra-options |
| 49 | (default '())))
|
| 50 |
|
| 51 | (define (home-kodi-services config)
|
| 52 | "Return a <shepherd-service> for kodi with CONFIG."
|
| 53 | (match-record config <home-kodi-configuration>
|
| 54 | (kodi extra-options)
|
| 55 | (let* ((kodi (file-append kodi "/bin/kodi"))
|
| 56 | (command #~'(#$kodi "-fs" #$@extra-options))
|
| 57 | (log-file #~(string-append %user-log-dir "/kodi.log")))
|
| 58 | (list (shepherd-service
|
| 59 | (documentation "Run the kodi media center.")
|
| 60 | (provision '(kodi))
|
| 61 | (modules '((shepherd support))) |
| 62 | (start #~(make-forkexec-constructor #$command
|
| 63 | #:log-file #$log-file))
|
| 64 | (stop #~(make-kill-destructor)))))))
|
| 65 |
|
| 66 | (define home-kodi-service-type
|
| 67 | (service-type
|
| 68 | (name 'home-kodi)
|
| 69 | (default-value (home-kodi-configuration))
|
| 70 | (extensions
|
| 71 | (list (service-extension home-shepherd-service-type
|
| 72 | home-kodi-services)))
|
| 73 | (description
|
| 74 | "Install and configure the Kodi media center so that it runs as a Shepherd
|
| 75 | service.")))
|
| 76 |
|
| 77 | (define-configuration home-jellyfin-mpv-shim-configuration
|
| 78 | (package
|
| 79 | (file-like jellyfin-mpv-shim)
|
| 80 | "The Jellyfin MPV Shim package to use"))
|
| 81 |
|
| 82 | (define (jellyfin-mpv-shim-shepherd-service config)
|
| 83 | (list (shepherd-service
|
| 84 | (documentation "Jellyfin MPV Shim.")
|
| 85 | (provision '(jellyfin-mpv-shim jellyfin-client))
|
| 86 |
|
| 87 | |
| 88 | |
| 89 | (requirement '(x11-display))
|
| 90 |
|
| 91 | (modules '((srfi srfi-1)
|
| 92 | (srfi srfi-26)
|
| 93 | (srfi srfi-98)))
|
| 94 | (start
|
| 95 | #~(make-forkexec-constructor
|
| 96 | (list
|
| 97 | #$(file-append
|
| 98 | (home-jellyfin-mpv-shim-configuration-package config)
|
| 99 | "/bin/jellyfin-mpv-shim"))))
|
| 100 | (stop #~(make-kill-destructor)))))
|
| 101 |
|
| 102 | (define-public home-jellyfin-mpv-shim-service-type
|
| 103 | (service-type
|
| 104 | (name 'home-jellyfin-mpv-shim)
|
| 105 | (extensions (list (service-extension home-shepherd-service-type
|
| 106 | jellyfin-mpv-shim-shepherd-service)
|
| 107 | |
| 108 | |
| 109 | (service-extension home-x11-service-type
|
| 110 | (const #t))))
|
| 111 | (default-value (home-jellyfin-mpv-shim-configuration))
|
| 112 | (description "Run Jellyfin MPV Shim.")))
|