1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (gnu services sound)
20 #:use-module (gnu services base)
21 #:use-module (gnu services configuration)
22 #:use-module (gnu services shepherd)
23 #:use-module (gnu services)
24 #:use-module (gnu system shadow)
25 #:use-module (guix gexp)
26 #:use-module (guix packages)
27 #:use-module (guix records)
28 #:use-module (guix store)
29 #:use-module (gnu packages linux)
30 #:use-module (gnu packages pulseaudio)
31 #:use-module (ice-9 match)
32 #:export (alsa-configuration
46 (define-record-type* <alsa-configuration>
47 alsa-configuration make-alsa-configuration alsa-configuration?
48 (alsa-plugins alsa-configuration-alsa-plugins ;<package>
49 (default alsa-plugins))
50 (pulseaudio? alsa-configuration-pulseaudio? ;boolean
52 (extra-options alsa-configuration-extra-options ;string
55 (define alsa-config-file
56 ;; Return the ALSA configuration file.
58 (($ <alsa-configuration> alsa-plugins pulseaudio? extra-options)
59 (apply mixed-text-file "asound.conf"
60 `("# Generated by 'alsa-service'.\n\n"
62 `("# Use PulseAudio by default
64 lib \"" ,#~(string-append #$alsa-plugins:pulseaudio
65 "/lib/alsa-lib/libasound_module_pcm_pulse.so") "\"
69 lib \"" ,#~(string-append #$alsa-plugins:pulseaudio
70 "/lib/alsa-lib/libasound_module_ctl_pulse.so") "\"
75 fallback \"sysdefault\"
78 description \"Default ALSA Output (currently PulseAudio Sound Server)\"
84 fallback \"sysdefault\"
89 (define (alsa-etc-service config)
90 (list `("asound.conf" ,(alsa-config-file config))))
92 (define alsa-service-type
96 (list (service-extension etc-service-type alsa-etc-service)))
97 (default-value (alsa-configuration))
98 (description "Configure low-level Linux sound support, ALSA.")))
100 ;;; sound.scm ends here