dotfiles/oni/home/services/mpv.scm

101 lines
3.2 KiB
Scheme

(define-module (oni home services mpv)
#:use-module ((gnu home services)
#:select (service-type
service-extension
home-profile-service-type
home-xdg-configuration-files-service-type))
#:use-module ((gnu services configuration)
#:select (serialize-package
define-configuration
define-configuration/no-serialization
text-config?
serialize-text-config))
#:use-module ((gnu packages video)
#:select (mpv mpv-mpris))
#:use-module ((guix packages)
#:select (package?))
#:use-module ((guix gexp)
#:select (mixed-text-file))
#:export (home-mpv-configuration
home-mpv-service-type
home-mpv-mpris-configuration
home-mpv-mpris-service-type))
(define-configuration/no-serialization home-mpv-extension
(configurations
(text-config '())
"The configuration foro the extension."))
(define-configuration home-mpv-configuration
(package
(package mpv)
"Package to use for setting mpv")
(configurations
(text-config '())
"Configuration for mpv."))
(define (add-mpv-packages config)
(list (home-mpv-configuration-package config)))
(define (home-mpv-extensions original-config extension-configs)
(home-mpv-configuration
(inherit original-config)
(configurations
(apply append (home-mpv-configuration-configurations original-config)
(map home-mpv-extension-configurations extension-configs)))))
(define (home-mpv-configuration-files config)
`(("mpv/mpv.conf"
,(mixed-text-file
"mpv.conf"
(serialize-text-config config (home-mpv-configuration-configurations config))))))
(define home-mpv-service-type
(service-type
(name 'home-mpv)
(extensions
(list (service-extension
home-profile-service-type
add-mpv-packages)
(service-extension
home-xdg-configuration-files-service-type
home-mpv-configuration-files)))
(compose identity)
(extend home-mpv-extensions)
(default-value (home-mpv-configuration))
(description "Install and configure Emacs.")))
(define-configuration/no-serialization home-mpv-mpris-configuration
(package
(package mpv-mpris)
"Package to use for setting mpv-mpris.")
(configurations
(text-config '())
"Configuration for mpv-mpris."))
(define (add-mpv-mpris config)
(home-mpv-extension
(configurations
(append
(list (mixed-text-file "mpris-config"
"scripts-append=" (home-mpv-mpris-configuration-package config) "/lib/mpris.so\n"))
(home-mpv-mpris-configuration-configurations config)))))
(define (add-mpv-mpris-packages config)
(list (home-mpv-mpris-configuration-package config)))
(define home-mpv-mpris-service-type
(service-type
(name 'home-mpv-mpris)
(extensions
(list (service-extension
home-mpv-service-type
add-mpv-mpris)
(service-extension
home-profile-service-type
add-mpv-mpris-packages)))
(compose identity)
(default-value (home-mpv-mpris-configuration))
(description "Install and configure mpv-mpris.")))