GNU bug report logs - #31297
[PATCH] gnu: Add sound service.

Previous Next

Package: guix-patches;

Reported by: Oleg Pykhalov <go.wigust <at> gmail.com>

Date: Sat, 28 Apr 2018 10:35:02 UTC

Severity: normal

Tags: patch

Done: Oleg Pykhalov <go.wigust <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31297 in the body.
You can then email your comments to 31297 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#31297; Package guix-patches. (Sat, 28 Apr 2018 10:35:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sat, 28 Apr 2018 10:35:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>
Subject: [PATCH] gnu: Add sound service.
Date: Sat, 28 Apr 2018 13:33:41 +0300
* 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 <go.wigust <at> 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 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>
+  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





Information forwarded to guix-patches <at> gnu.org:
bug#31297; Package guix-patches. (Mon, 30 Apr 2018 20:56:02 GMT) Full text and rfc822 format available.

Message #8 received at 31297 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 31297 <at> debbugs.gnu.org
Subject: Re: [bug#31297] [PATCH] gnu: Add sound service.
Date: Mon, 30 Apr 2018 22:55:31 +0200
Hello,

Oleg Pykhalov <go.wigust <at> gmail.com> skribis:

> * gnu/services/sound.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add this.
> * doc/guix.texi (Sound Services): New chapter.

[...]

> +@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.

Is this file required to get PulseAudio support?  I realize I have
~/.asoundrc that’s similar to what this new service does, so it may be
that I simply forgot that things wouldn’t work well without it.

> +@deffn {Scheme Variable} alsa-service-type
> +This is the type for the @uref{https://alsa-project.org/, alsa},

s/alsa/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 #f)))

s/#f/""/ since it’s a string.

> +(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)))))))

I think you could instead write:

  (if (alsa-configuration-pulseaudio? config)
      (plain-file "asound.conf" (string-append "# Generated by…" extra-options))
      (plain-file "asound.conf" extra-options))

> +(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"))))

Please extend ‘etc-service-type’ instead.

> +(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.")))

“Configure low-level Linux sound support, ALSA.”

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#31297; Package guix-patches. (Tue, 01 May 2018 09:40:02 GMT) Full text and rfc822 format available.

Message #11 received at 31297 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 31297 <at> debbugs.gnu.org
Subject: Re: [bug#31297] [PATCH] gnu: Add sound service.
Date: Tue, 01 May 2018 12:39:31 +0300
[Message part 1 (text/plain, inline)]
Hello Ludovic,

Thank you for review!

ludo <at> gnu.org (Ludovic Courtès) writes:

> Oleg Pykhalov <go.wigust <at> gmail.com> skribis:
>
>> * gnu/services/sound.scm: New file.
>> * gnu/local.mk (GNU_SYSTEM_MODULES): Add this.
>> * doc/guix.texi (Sound Services): New chapter.
>
> [...]
>
>> +@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.
>
> Is this file required to get PulseAudio support?  I realize I have
> ~/.asoundrc that’s similar to what this new service does, so it may be
> that I simply forgot that things wouldn’t work well without it.

In case of existing ‘~/.asoundrc’ it's not required.  But I spent some
time to find a ‘asoundrc’ config and be glad if it was in a Guix manual.

[…]

I also replaced “to” with “by” in
“Whether to use Pulseaudio by configuring ALSA to use PulseAudio.”
                           ^^
sentence in Guix documentation.

[0001-gnu-Add-sound-service.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
Oleg.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#31297; Package guix-patches. (Tue, 01 May 2018 20:04:02 GMT) Full text and rfc822 format available.

Message #14 received at 31297 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 31297 <at> debbugs.gnu.org
Subject: Re: [bug#31297] [PATCH] gnu: Add sound service.
Date: Tue, 01 May 2018 22:03:52 +0200
Hello Oleg,

Oleg Pykhalov <go.wigust <at> gmail.com> skribis:

> ludo <at> gnu.org (Ludovic Courtès) writes:
>
>> Oleg Pykhalov <go.wigust <at> gmail.com> skribis:
>>
>>> * gnu/services/sound.scm: New file.
>>> * gnu/local.mk (GNU_SYSTEM_MODULES): Add this.
>>> * doc/guix.texi (Sound Services): New chapter.
>>
>> [...]
>>
>>> +@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.
>>
>> Is this file required to get PulseAudio support?  I realize I have
>> ~/.asoundrc that’s similar to what this new service does, so it may be
>> that I simply forgot that things wouldn’t work well without it.
>
> In case of existing ‘~/.asoundrc’ it's not required.  But I spent some
> time to find a ‘asoundrc’ config and be glad if it was in a Guix manual.

Right, I agree.

> From 460fa678823a7cf3d2869a3e4beafb22e5a313fa Mon Sep 17 00:00:00 2001
> From: Oleg Pykhalov <go.wigust <at> gmail.com>
> Date: Sat, 28 Apr 2018 13:30:20 +0300
> Subject: [PATCH] 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.

[...]

> +@node Sound Services
> +@subsubsection Sound Services
> +

Maybe add “@cindex sound support”, “@cindex ALSA”, and
“@cindex PulseAudio, sound support”.

> +The @code{(gnu services alsa)} module provides an
                           ^^
“sound”

> +@code{alsa-service-type} service to generate an ALSA
> +@file{/etc/asound.conf} configuration file.

Perhaps add a sentence like: “This configuration file is what allows
applications that produce sound using ALSA to be correctly handled.”

> +@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 by configuring ALSA to use PulseAudio.

“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{#f})

default: @code{""}

> +Extra options is a string which will be appended to asound.conf file.

Just: “String to append to the @file{asound.conf} file.”

Apologies for not catching those earlier!

You can push with changes along these lines.

Thank you!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#31297; Package guix-patches. (Tue, 01 May 2018 20:06:01 GMT) Full text and rfc822 format available.

Message #17 received at 31297 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 31297 <at> debbugs.gnu.org
Subject: Re: [bug#31297] [PATCH] gnu: Add sound service.
Date: Tue, 01 May 2018 22:04:59 +0200
Also, in a separate patch, it may be useful to add (service
alsa-service-type) to %desktop-services.

What do people think?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#31297; Package guix-patches. (Wed, 02 May 2018 11:43:01 GMT) Full text and rfc822 format available.

Message #20 received at 31297 <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <mbakke <at> fastmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>, Oleg Pykhalov
 <go.wigust <at> gmail.com>
Cc: 31297 <at> debbugs.gnu.org
Subject: Re: [bug#31297] [PATCH] gnu: Add sound service.
Date: Wed, 02 May 2018 13:41:55 +0200
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Also, in a separate patch, it may be useful to add (service
> alsa-service-type) to %desktop-services.
>
> What do people think?

I also had a ~/.asoundrc since forever that is very similar to the one
added by this service.  So it makes sense to provide it with
%desktop-services.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#31297; Package guix-patches. (Wed, 02 May 2018 12:16:01 GMT) Full text and rfc822 format available.

Message #23 received at 31297 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 31297 <at> debbugs.gnu.org
Subject: Re: [bug#31297] [PATCH] gnu: Add sound service.
Date: Wed, 02 May 2018 15:15:05 +0300
[Message part 1 (text/plain, inline)]
“gnu: Add sound service.” pushed as
8cd1e8e84926dc6ed1012a17609dea2d20ac41b4

ludo <at> gnu.org (Ludovic Courtès) writes:

> Also, in a separate patch, it may be useful to add (service
> alsa-service-type) to %desktop-services.
>
> What do people think?

[…]

I'm agree.

[0001-services-desktop-Add-alsa-service-type.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
Oleg.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#31297; Package guix-patches. (Thu, 03 May 2018 20:33:01 GMT) Full text and rfc822 format available.

Message #26 received at 31297 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 31297 <at> debbugs.gnu.org
Subject: Re: [bug#31297] [PATCH] gnu: Add sound service.
Date: Thu, 03 May 2018 22:32:53 +0200
Oleg Pykhalov <go.wigust <at> gmail.com> skribis:

> From 47b00837a8109f4b18e1de28d6f1b72524af18a9 Mon Sep 17 00:00:00 2001
> From: Oleg Pykhalov <go.wigust <at> gmail.com>
> Date: Wed, 2 May 2018 15:01:37 +0300
> Subject: [PATCH] services: desktop: Add alsa-service-type.
>
> * gnu/services/desktop.scm (%desktop-services): Add 'alsa-service-type'.

LGTM, thank you!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#31297; Package guix-patches. (Fri, 11 May 2018 09:18:02 GMT) Full text and rfc822 format available.

Message #29 received at 31297 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 31297 <at> debbugs.gnu.org, 31297-done <at> debbugs.gnu.org
Subject: Re: [bug#31297] [PATCH] gnu: Add sound service.
Date: Fri, 11 May 2018 12:17:11 +0300
[Message part 1 (text/plain, inline)]
ludo <at> gnu.org (Ludovic Courtès) writes:

> Oleg Pykhalov <go.wigust <at> gmail.com> skribis:
>
>> From 47b00837a8109f4b18e1de28d6f1b72524af18a9 Mon Sep 17 00:00:00 2001
>> From: Oleg Pykhalov <go.wigust <at> gmail.com>
>> Date: Wed, 2 May 2018 15:01:37 +0300
>> Subject: [PATCH] services: desktop: Add alsa-service-type.
>>
>> * gnu/services/desktop.scm (%desktop-services): Add 'alsa-service-type'.
>
> LGTM, thank you!

Pushed as ef6a484475e7473131efd9a41473c1f25a6b0d0c

I'll close the bug report.

Oleg.
[signature.asc (application/pgp-signature, inline)]

Reply sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
You have taken responsibility. (Fri, 11 May 2018 09:18:02 GMT) Full text and rfc822 format available.

Notification sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
bug acknowledged by developer. (Fri, 11 May 2018 09:18:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 08 Jun 2018 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 14 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.