gnu: Add sound service.

* gnu/services/sound.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add this.
* doc/guix.texi (Sound Services): New chapter.
master
Oleg Pykhalov 2018-04-28 13:30:20 +03:00
parent fb5b359d77
commit 8cd1e8e849
No known key found for this signature in database
GPG Key ID: 7246E11C69B79569
3 changed files with 131 additions and 0 deletions

View File

@ -235,6 +235,7 @@ Services
* X Window:: Graphical display.
* Printing Services:: Local and remote printer support.
* Desktop Services:: D-Bus and desktop services.
* Sound Services:: ALSA and Pulseaudio services.
* Database Services:: SQL databases, key-value stores, etc.
* Mail Services:: IMAP, POP3, SMTP, and all that.
* Messaging Services:: Messaging services.
@ -9697,6 +9698,7 @@ declaration.
* X Window:: Graphical display.
* Printing Services:: Local and remote printer support.
* Desktop Services:: D-Bus and desktop services.
* Sound Services:: ALSA and Pulseaudio services.
* Database Services:: SQL databases, key-value stores, etc.
* Mail Services:: IMAP, POP3, SMTP, and all that.
* Messaging Services:: Messaging services.
@ -12842,6 +12844,48 @@ bluetooth keyboard or mouse.
Users need to be in the @code{lp} group to access the D-Bus service.
@end deffn
@node Sound Services
@subsubsection Sound Services
@cindex sound support
@cindex ALSA
@cindex PulseAudio, sound support
The @code{(gnu services sound)} module provides an
@code{alsa-service-type} service to generate an ALSA
@file{/etc/asound.conf} configuration file. This configuration file is
what allows applications that produce sound using ALSA to be correctly
handled.
@deffn {Scheme Variable} alsa-service-type
This is the type for the @uref{https://alsa-project.org/, ALSA},
@command{alsa-configuration} record as in this example:
@example
(service alsa-service-type)
@end example
See below for details about @code{alsa-configuration}.
@end deffn
@deftp {Data Type} alsa-configuration
Data type representing the configuration for @code{alsa-service}.
@table @asis
@item @code{pulseaudio?} (default: @var{#t})
Whether ALSA applications should transparently be made to use the
@uref{http://www.pulseaudio.org/, PulseAudio} sound server.
Using PulseAudio allows you to run several sound-producing applications
at the same time and to individual control them @i{via}
@command{pavucontrol}, among other things.
@item @code{extra-options} (default: @var{""})
String to append to the @file{asound.conf} file.
@end table
@end deftp
@node Database Services
@subsubsection Database Services

View File

@ -480,6 +480,7 @@ GNU_SYSTEM_MODULES = \
%D%/services/networking.scm \
%D%/services/nfs.scm \
%D%/services/shepherd.scm \
%D%/services/sound.scm \
%D%/services/herd.scm \
%D%/services/pm.scm \
%D%/services/rsync.scm \

86
gnu/services/sound.scm Normal file
View File

@ -0,0 +1,86 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu services sound)
#:use-module (gnu services base)
#:use-module (gnu services configuration)
#:use-module (gnu services shepherd)
#:use-module (gnu services)
#:use-module (gnu system shadow)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix records)
#:use-module (guix store)
#:use-module (gnu packages pulseaudio)
#:use-module (ice-9 match)
#:export (alsa-configuration
alsa-service-type))
;;; Commentary:
;;;
;;; Sound services.
;;;
;;; Code:
;;;
;;; ALSA
;;;
(define-record-type* <alsa-configuration>
alsa-configuration make-alsa-configuration alsa-configuration?
(pulseaudio? alsa-configuration-pulseaudio? ;boolean
(default #t))
(extra-options alsa-configuration-extra-options ;string
(default "")))
(define (alsa-config-file config)
"Return the ALSA configuration file corresponding to CONFIG."
(plain-file "asound.conf"
(string-append "# Generated by 'alsa-service'.\n\n"
(if (alsa-configuration-pulseaudio? config)
"# Use PulseAudio by default
pcm.!default {
type pulse
fallback \"sysdefault\"
hint {
show on
description \"Default ALSA Output (currently PulseAudio Sound Server)\"
}
}
ctl.!default {
type pulse
fallback \"sysdefault\"
}
"
"")
(alsa-configuration-extra-options config))))
(define (alsa-etc-service config)
(list `("asound.conf" ,(alsa-config-file config))))
(define alsa-service-type
(service-type
(name 'alsa)
(extensions
(list (service-extension etc-service-type alsa-etc-service)))
(default-value (alsa-configuration))
(description "Configure low-level Linux sound support, ALSA.")))
;;; sound.scm ends here