From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fCNC5-0004OD-SW for guix-patches@gnu.org; Sat, 28 Apr 2018 06:35:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fCNC2-0003Xq-LG for guix-patches@gnu.org; Sat, 28 Apr 2018 06:35:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:33711) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fCNC2-0003Xh-Gz for guix-patches@gnu.org; Sat, 28 Apr 2018 06:35:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fCNC2-0007aj-8a for guix-patches@gnu.org; Sat, 28 Apr 2018 06:35:02 -0400 Subject: [bug#31297] [PATCH] gnu: Add sound service. Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fCNAy-0003od-LR for guix-patches@gnu.org; Sat, 28 Apr 2018 06:33:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fCNAv-0003Hg-1q for guix-patches@gnu.org; Sat, 28 Apr 2018 06:33:56 -0400 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:35601) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fCNAu-0003HF-OF for guix-patches@gnu.org; Sat, 28 Apr 2018 06:33:52 -0400 Received: by mail-wm0-x233.google.com with SMTP id o78so6969057wmg.0 for ; Sat, 28 Apr 2018 03:33:52 -0700 (PDT) From: Oleg Pykhalov Date: Sat, 28 Apr 2018 13:33:41 +0300 Message-Id: <20180428103341.30675-1-go.wigust@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 31297@debbugs.gnu.org * gnu/services/sound.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add this. * doc/guix.texi (Sound Services): New chapter. --- doc/guix.texi | 33 +++++++++++++++ gnu/local.mk | 1 + gnu/services/sound.scm | 95 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 gnu/services/sound.scm diff --git a/doc/guix.texi b/doc/guix.texi index 75886e94b..b057f67cb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -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. @@ -12804,6 +12806,37 @@ 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 + +The @code{(gnu services alsa)} module provides an +@code{alsa-service-type} service to generate an ALSA +@file{/etc/asound.conf} configuration file. + +@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 to use Pulseaudio for configuring ALSA to use PulseAudio. + +@item @code{extra-options} (default: @var{#f}) +Extra options is a string which will be appended to asound.conf file. + +@end table +@end deftp + @node Database Services @subsubsection Database Services diff --git a/gnu/local.mk b/gnu/local.mk index cbf2c6f1b..b649ae008 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -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 \ diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm new file mode 100644 index 000000000..b34e0efc1 --- /dev/null +++ b/gnu/services/sound.scm @@ -0,0 +1,95 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2018 Oleg Pykhalov +;;; +;;; 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 . + +(define-module (gnu services sound) + #:use-module (gnu services base) + #:use-module (gnu services configuration) + #:use-module (gnu services shepherd) + #:use-module (gnu services web) + #: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 make-alsa-configuration alsa-configuration? + (pulseaudio? alsa-configuration-pulseaudio? ;boolean + (default #t)) + (extra-options alsa-configuration-extra-options ;string + (default #f))) + +(define (alsa-config-file config) + "Return the ALSA configuration file corresponding to CONFIG." + (computed-file + "asound.conf" + #~(call-with-output-file #$output + (lambda (port) + (display "# Generated by 'alsa-service'.\n\n" port) + (when #$(alsa-configuration-pulseaudio? config) + (display "# 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\" +} +" + port)) + (let ((extra-options #$(alsa-configuration-extra-options config))) + (when extra-options (display extra-options port))))))) + +(define (alsa-activation config) + "Return the activation GEXP for CONFIG." + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (copy-file #$(alsa-config-file config) "/etc/asound.conf")))) + +(define alsa-service-type + (service-type + (name 'alsa) + (extensions + (list (service-extension activation-service-type alsa-activation))) + (default-value (alsa-configuration)) + (description "Configure the alsa."))) + +;;; alsa.scm ends here -- 2.17.0