Add MPD configuration
This also includes an attempt at installing a custom SCSH that defines some search paths. But unfortunately it didn't work, so the SCSH ends up being the usual one and the ‘mpd-random-albums’ package doesn't actually work. The main MPD configuration does work, though. This also includes the instruction to install tmsu which I want to try out again.
This commit is contained in:
parent
b2e72743de
commit
5f46121fc7
7 changed files with 213 additions and 6 deletions
|
@ -5,6 +5,7 @@
|
|||
#:use-module (gnu packages commencement)
|
||||
#:use-module (gnu packages emacs)
|
||||
#:use-module (gnu packages emacs-xyz)
|
||||
#:use-module (gnu packages file-systems)
|
||||
#:use-module (gnu packages linux)
|
||||
#:use-module (gnu packages music)
|
||||
#:use-module (gnu packages video)
|
||||
|
@ -32,7 +33,10 @@
|
|||
#:use-module (oni packages notmuch-collect-tasks)
|
||||
#:use-module (oni packages notmuch-tag-mailinglists)
|
||||
#:use-module (oni packages pick-random-wallpaper)
|
||||
#:use-module (oni packages shutdown-rofi))
|
||||
#:use-module (oni packages shutdown-rofi)
|
||||
#:use-module (oni packages mpd-random-albums)
|
||||
#:use-module (oni home services mpd)
|
||||
#:use-module (oop goops))
|
||||
|
||||
(define (with-master-branch package)
|
||||
"Apply a transformation to PACKAGE so that it uses the master branch."
|
||||
|
@ -55,6 +59,8 @@
|
|||
emacs-org-roam
|
||||
emacs-vterm
|
||||
fakeroot ; Needed for build arch packages
|
||||
tmsu
|
||||
mpd-random-albums
|
||||
))
|
||||
|
||||
(services
|
||||
|
@ -106,4 +112,20 @@
|
|||
(home-emacs-configuration
|
||||
(package emacs-next)))
|
||||
|
||||
(service home-flameshot-service-type))))
|
||||
(service home-flameshot-service-type)
|
||||
|
||||
(service home-mpd-service-type
|
||||
(home-mpd-configuration
|
||||
(music-directory "~/music")
|
||||
(playlist-directory "~/music/playlists")
|
||||
(log-file "~/.local/share/mpd/mpd.log")
|
||||
(pid-file "~/.local/share/mpd/mpd.pid")
|
||||
(db-file "~/.local/share/mpd/mpd.db")
|
||||
(state-file "~/.local/share/mpd/mpdstate")
|
||||
(audio-outputs
|
||||
(list (make <home-mpd-audio-output> #:type "pulse" #:name "MPD Pulse")
|
||||
(make <home-mpd-audio-output>
|
||||
#:type "fifo"
|
||||
#:name "Visualizer"
|
||||
#:path "/tmp/mpd.fifo"
|
||||
#:format "44100:16:2"))))))))
|
||||
|
|
124
oni/home/services/mpd.scm
Normal file
124
oni/home/services/mpd.scm
Normal file
|
@ -0,0 +1,124 @@
|
|||
(define-module (oni home services mpd)
|
||||
#:use-module (gnu services configuration)
|
||||
#:use-module (gnu packages mpd)
|
||||
#:use-module (gnu home services)
|
||||
#:use-module (gnu home services shepherd)
|
||||
#:use-module (gnu home services utils)
|
||||
#:use-module (guix packages)
|
||||
#:use-module (guix gexp)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (oop goops)
|
||||
#:use-module (ice-9 string-fun)
|
||||
|
||||
#:export (home-mpd-service-type
|
||||
home-mpd-configuration
|
||||
<home-mpd-audio-output>))
|
||||
|
||||
(define (serialize-boolean field value)
|
||||
"")
|
||||
|
||||
(define (serialize-home-mpd-audio-output config)
|
||||
(let ((type (slot-ref config 'type))
|
||||
(name (slot-ref config 'name))
|
||||
(path (slot-ref config 'path))
|
||||
(fmt (slot-ref config 'format)))
|
||||
(list "audio_output {"
|
||||
(format #f " type ~s" type)
|
||||
(format #f " name ~s" name)
|
||||
(if path (format #f " path ~s" path) "")
|
||||
(if fmt (format #f " format ~s" fmt) "")
|
||||
"}")))
|
||||
|
||||
(define (serialize-home-mpd-audio-output-list field value)
|
||||
(string-join
|
||||
(apply append (map serialize-home-mpd-audio-output value))
|
||||
"\n"))
|
||||
|
||||
(define (serialize-string field value)
|
||||
(format #f "~a ~s\n" (string-replace-substring (symbol->string field) "-" "_") value))
|
||||
|
||||
(define (type? value)
|
||||
(member value '("shout" "null" "fifo" "pipe" "alsa" "ao" "oss" "openal"
|
||||
"solaris" "pipewire" "pulse" "jack" "httpd" "snapcast"
|
||||
"recorder")))
|
||||
|
||||
(define (home-mpd-audio-output-list? value)
|
||||
(and (list? value)
|
||||
(every (lambda (v) (is-a? v <home-mpd-audio-output>)) value)))
|
||||
|
||||
(define-maybe string)
|
||||
(define-maybe home-mpd-audio-output-list)
|
||||
|
||||
(define-configuration home-mpd-configuration
|
||||
(package
|
||||
(package mpd)
|
||||
"Package to use for settings MPD")
|
||||
(auto-start?
|
||||
(boolean #t)
|
||||
"Should MPD be started automatically")
|
||||
(db-file
|
||||
maybe-string
|
||||
"Where the db file will be stored")
|
||||
(log-file
|
||||
maybe-string
|
||||
"Where the log file should be located")
|
||||
(pid-file
|
||||
maybe-string
|
||||
"The file to save mpd's process ID in")
|
||||
(music-directory
|
||||
maybe-string
|
||||
"The directory where music is located")
|
||||
(playlist-directory
|
||||
maybe-string
|
||||
"The directory where saved playlists are stored")
|
||||
(state-file
|
||||
maybe-string
|
||||
"Specifies if a state file is used and where it is located")
|
||||
(audio-outputs
|
||||
maybe-home-mpd-audio-output-list
|
||||
"Output configurations"))
|
||||
|
||||
(define-class <home-mpd-audio-output> ()
|
||||
(type #:init-keyword #:type)
|
||||
(name #:init-keyword #:name)
|
||||
(path #:init-keyword #:path #:init-value #f)
|
||||
(format #:init-keyword #:format #:init-value #f))
|
||||
|
||||
(define (add-mpd-packages config)
|
||||
(list (home-mpd-configuration-package config)))
|
||||
|
||||
(define (serialize-mpd-configuration config)
|
||||
(serialize-configuration config home-mpd-configuration-fields))
|
||||
|
||||
(define (home-mpd-configuration-file config)
|
||||
(mixed-text-file
|
||||
"mpd.conf"
|
||||
(serialize-mpd-configuration config)))
|
||||
|
||||
(define (home-mpd-shepherd-service config)
|
||||
(list
|
||||
(shepherd-service
|
||||
(documentation "Start MPD")
|
||||
(provision '(mpd))
|
||||
(auto-start? (home-mpd-configuration-auto-start? config))
|
||||
(start
|
||||
#~(make-forkexec-constructor
|
||||
(list #$(file-append (home-mpd-configuration-package config) "/bin/mpd")
|
||||
"--no-daemon"
|
||||
#$(home-mpd-configuration-file config))
|
||||
#:log-file (format #f "~a/.local/var/log/mpd.log" (getenv "HOME"))))
|
||||
(stop #~(make-kill-destructor)))))
|
||||
|
||||
(define home-mpd-service-type
|
||||
(service-type
|
||||
(name 'home-mpd)
|
||||
(extensions
|
||||
(list (service-extension
|
||||
home-profile-service-type
|
||||
add-mpd-packages)
|
||||
(service-extension
|
||||
home-shepherd-service-type
|
||||
home-mpd-shepherd-service)))
|
||||
(compose identity)
|
||||
(default-value (home-mpd-configuration))
|
||||
(description "Install and configure mpd.")))
|
|
@ -5,7 +5,7 @@
|
|||
#:use-module ((guix licenses) #:prefix license:)
|
||||
#:use-module (gnu packages base)
|
||||
#:use-module (gnu packages bash)
|
||||
#:use-module (gnu packages shells)
|
||||
#:use-module (oni packages scsh)
|
||||
#:use-module (gnu packages mail))
|
||||
|
||||
(define-public count-emails
|
||||
|
@ -24,7 +24,7 @@
|
|||
(base32 "0pv4wbxbg0szs2jiskmxvivrq44ha5ljdn18j3j2pi8q1dp9rmb3"))
|
||||
(file-name (git-file-name name version))))
|
||||
(propagated-inputs
|
||||
(list bash scsh notmuch))
|
||||
(list scsh notmuch))
|
||||
(build-system gnu-build-system)
|
||||
(arguments
|
||||
`(#:tests? #f
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#:use-module (guix build-system gnu)
|
||||
#:use-module ((guix licenses) #:prefix license:)
|
||||
#:use-module (gnu packages base)
|
||||
#:use-module (gnu packages shells)
|
||||
#:use-module (oni packages scsh)
|
||||
#:use-module (gnu packages xdisorg)
|
||||
#:use-module (gnu packages gawk)
|
||||
#:use-module (oni packages hlwm-switch-to-window))
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#:use-module ((guix licenses) #:prefix license:)
|
||||
#:use-module (gnu packages base)
|
||||
#:use-module (gnu packages bash)
|
||||
#:use-module (gnu packages shells))
|
||||
#:use-module (oni packages scsh))
|
||||
|
||||
(define-public (inbox-size emacs)
|
||||
(let ((commit "e9a94db05e45be9357ccc757601c1cd890a6254c")
|
||||
|
|
44
oni/packages/mpd-random-albums.scm
Normal file
44
oni/packages/mpd-random-albums.scm
Normal file
|
@ -0,0 +1,44 @@
|
|||
(define-module (oni packages mpd-random-albums)
|
||||
#:use-module ((guix licenses) #:prefix license:)
|
||||
#:use-module (gnu packages base)
|
||||
#:use-module (gnu packages bash)
|
||||
#:use-module (gnu packages mpd)
|
||||
#:use-module (guix build-system gnu)
|
||||
#:use-module (guix git-download)
|
||||
#:use-module (guix packages)
|
||||
#:use-module (oni packages scsh))
|
||||
|
||||
(define-public mpd-random-albums
|
||||
(let ((commit "c12a766e1920e726129dfd1161a2ef15471f89e8")
|
||||
(revision "0"))
|
||||
(package
|
||||
(name "mpd-random-albums")
|
||||
(version (git-version "0.0.0" revision commit))
|
||||
(source
|
||||
(origin
|
||||
(uri (git-reference
|
||||
(url "git://ryuslash.org/util/tom/mpd-random-albums")
|
||||
(commit commit)))
|
||||
(method git-fetch)
|
||||
(sha256
|
||||
(base32 "0mgs9377hw3x1nfcah3wwr3zijvzrkqicvgrbcjl3g1p4fmlb8mr"))
|
||||
(file-name (git-file-name name version))))
|
||||
(propagated-inputs
|
||||
(list mpd bash scsh))
|
||||
(build-system gnu-build-system)
|
||||
(arguments
|
||||
`(#:tests? #f
|
||||
#:phases
|
||||
(modify-phases %standard-phases
|
||||
(delete 'configure)
|
||||
(delete 'build)
|
||||
(replace 'install
|
||||
(lambda* (#:key outputs #:allow-other-keys)
|
||||
(let ((bin (string-append (assoc-ref outputs "out") "/bin"))
|
||||
(site (string-append (assoc-ref outputs "out") "/share/scsh-0.7")))
|
||||
(install-file "mpd-random-albums" bin)
|
||||
(install-file "mpd.scm" site)))))))
|
||||
(home-page "https://ryuslash.org/")
|
||||
(synopsis "A simple script that populates the MPD playlist with all of my albums in random order.")
|
||||
(description "Creates a new playlist in MPD with all of the albums in my database and shuffles them by album.")
|
||||
(license license:gpl3+))))
|
17
oni/packages/scsh.scm
Normal file
17
oni/packages/scsh.scm
Normal file
|
@ -0,0 +1,17 @@
|
|||
(define-module (oni packages scsh)
|
||||
#:use-module ((guix licenses) #:prefix license:)
|
||||
#:use-module (gnu packages autotools)
|
||||
#:use-module ((gnu packages shells) #:prefix shells:)
|
||||
#:use-module (guix build-system gnu)
|
||||
#:use-module (guix git-download)
|
||||
#:use-module (guix packages))
|
||||
|
||||
(define-public scsh
|
||||
(package
|
||||
(inherit shells:scsh)
|
||||
;; (native-search-paths
|
||||
;; (list (search-path-specification
|
||||
;; (variable "SCSH_LIB_DIRS")
|
||||
;; (separator #f)
|
||||
;; (files '("share/scsh-0.7")))))
|
||||
))
|
Loading…
Reference in a new issue