From cb16d6af6182368a2db5a98d3cb62c0de36b676a Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 8 Oct 2023 22:07:36 -0700 Subject: [PATCH] Add mpv and mpv-mpris services --- oni/home/config/rincewind.scm | 11 ++-- oni/home/services/mpv.scm | 101 ++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 oni/home/services/mpv.scm diff --git a/oni/home/config/rincewind.scm b/oni/home/config/rincewind.scm index a3754e6..b28bc25 100644 --- a/oni/home/config/rincewind.scm +++ b/oni/home/config/rincewind.scm @@ -37,9 +37,6 @@ tree-sitter-org tree-sitter-json tree-sitter-css)) - #:use-module ((gnu packages video) - #:select (mpv - mpv-mpris)) #:use-module ((gnu packages) #:select (specification->package+output)) #:use-module ((gnu services) @@ -92,6 +89,9 @@ home-mpc-update-service-type home-mpd-notify-service-type)) + #:use-module ((oni home services mpv) + #:select (home-mpv-service-type + home-mpv-mpris-service-type)) #:use-module ((oni home services notmuch) #:select (home-notmuch-service-type home-notmuch-configuration)) @@ -249,7 +249,7 @@ (define my-emacs emacs-next-tree-sitter) (home-environment - (packages (list mpv mpv-mpris easytag + (packages (list easytag (specification->package+output "glibc-locales") (specification->package+output "font-fantasque-sans") (specification->package+output "font-comic-neue") @@ -448,6 +448,9 @@ (service home-mpc-update-service-type) (service home-mpd-notify-service-type) + (service home-mpv-service-type) + (service home-mpv-mpris-service-type) + (service home-stumpwm-service-type (home-stumpwm-configuration (package stumpwm+swank) diff --git a/oni/home/services/mpv.scm b/oni/home/services/mpv.scm new file mode 100644 index 0000000..2c6d791 --- /dev/null +++ b/oni/home/services/mpv.scm @@ -0,0 +1,101 @@ +(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.")))