From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 4OhGBE22+WFweQEAgWs5BA (envelope-from ) for ; Tue, 01 Feb 2022 23:38:05 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 8GH4AE22+WFflQAAauVa8A (envelope-from ) for ; Tue, 01 Feb 2022 23:38:05 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 684E11C6B3 for ; Tue, 1 Feb 2022 23:38:04 +0100 (CET) Received: from localhost ([::1]:52830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nF1mk-0001tM-Nn for larch@yhetil.org; Tue, 01 Feb 2022 17:38:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEzGw-0007PC-H0 for guix-patches@gnu.org; Tue, 01 Feb 2022 14:57:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:51305) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEzGv-000697-N5 for guix-patches@gnu.org; Tue, 01 Feb 2022 14:57:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nEzGv-0001FC-Jq for guix-patches@gnu.org; Tue, 01 Feb 2022 14:57:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53676] [PATCH 4/5] services: pulseaudio: Add an extra-script-files configuration field. Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 01 Feb 2022 19:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53676 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer , 53676@debbugs.gnu.org Received: via spool by 53676-submit@debbugs.gnu.org id=B53676.16437453984746 (code B ref 53676); Tue, 01 Feb 2022 19:57:01 +0000 Received: (at 53676) by debbugs.gnu.org; 1 Feb 2022 19:56:38 +0000 Received: from localhost ([127.0.0.1]:44208 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nEzGX-0001ET-Kw for submit@debbugs.gnu.org; Tue, 01 Feb 2022 14:56:38 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:46897) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nEzGV-0001EG-Ee for 53676@debbugs.gnu.org; Tue, 01 Feb 2022 14:56:36 -0500 Received: by mail-ed1-f65.google.com with SMTP id m11so36733073edi.13 for <53676@debbugs.gnu.org>; Tue, 01 Feb 2022 11:56:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=ene8wyLAejHBso8IBNBosNG7YA9oZLLX4Hve6jrk2tg=; b=VS0bOcKCN9SAq1VkTq3IJyzQSBYg1s8/lJErxrQllLAAV+7nHrwKOLuXHIKh+3bZC5 P9XOq/1yXsFX21CawI+bc/ynCRENkUH6ZjVDrnWXvEtlWReYw2w7LU1GZeKhPDvqTllc AsYZxVYHdqjoLaDy3mpVnKm1AunMc/vIQBJADyQscWLblgg6omYRkWBHx9lL6h1HoqNu IoNDbMbsMMkZCu4JCaq7M5+wCDFCMjg5+mVYDarUBaaA2Oi8BujGcvUFNZm5IedootzK H6Xz2tDZ42YhyjuuwCYAMfPYnCWxRYB+yNAM2u5iqHEFILcijR/IvPBbw0bC+PrNNNoP ynpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=ene8wyLAejHBso8IBNBosNG7YA9oZLLX4Hve6jrk2tg=; b=URmmyPPJlQF1i7TXtVgTnwT2VK4JNSupXXWFcNggK441gK1ukQVPZCccC1dCmklzXJ oluuar0OfwRPYdlwzBC91KnlHiAGbMelE87rCoUCl5+5ZTX4KFfoQ+Eq/OiMgBXhxf24 R5tmXWsGWa5DeBOkrU2fySEkRwLu/6FVsSpZkoBQk2dLkBGFva6iKtmHuT1oYrkMBa0l cs+1XmP2C3+9P+HFz2K73bz0yTiBvxCvKaG+6/yTZVz9H2jy6bSQ/zYMF2wEtwJjC3UE RbzyXANO7Tj4nkKUqsJTsAhrNiOta07CFxZ/T+RytJbJ/onXLCxg4mAwbxJLOcNRmXPj v4xA== X-Gm-Message-State: AOAM531+HREbu2K2nCjDCqxYKZrjeLa7T0fRrd3MkpnRphgCxMrKdxhh Jj4WkREZLekSPe1s3I+sqxs= X-Google-Smtp-Source: ABdhPJzbwinXU8LUjX63MyiUoUstYFe5Nf7JF66AIfwiwpfUlMwRVz9+VsGyvE4Ej+IMzwg0eI8KUw== X-Received: by 2002:a05:6402:3450:: with SMTP id l16mr26943948edc.225.1643745389490; Tue, 01 Feb 2022 11:56:29 -0800 (PST) Received: from nijino.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id u18sm14886940eje.37.2022.02.01.11.56.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 11:56:29 -0800 (PST) Message-ID: <97111754acacc576aec4eb55889a32474fe71f95.camel@gmail.com> From: Liliana Marie Prikler Date: Tue, 01 Feb 2022 20:56:28 +0100 In-Reply-To: <20220201041933.16603-4-maxim.cournoyer@gmail.com> References: <20220201041933.16603-1-maxim.cournoyer@gmail.com> <20220201041933.16603-4-maxim.cournoyer@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1643755084; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=ene8wyLAejHBso8IBNBosNG7YA9oZLLX4Hve6jrk2tg=; b=Owwkijmj2Mb+dzDkUR2W7jIny4nnLqvqzTNL2wCU2c+Nd3l9dkl1oRoFfiHQOypZ/nHtfq GxGZlKneuBaNjNKBu9n9Bse+hHpZ7u1t6UeqhFNR6szpEZ2LuPuOzyRCHzf4OSq10eCEXd yG6Ku11ZWx41rg+kI0EKHMOTq7SFs15cwyfsCaBSNgIWoNmAFrkg4tVzuBxTNLIVyuobqq GI/QuL7fRw4J8l5A49Zh9OO3rlCj/rc4deYEFPG4VZaVl0XXAzDIo6WFxMh2cI5o7iIdbU l2JbR9oahRs7ZOl5RH9DndFyATWa9pBaz8HtlrHBbLhGrqSRYL+gfQvar8A5RQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643755084; a=rsa-sha256; cv=none; b=VXJ51FcdeYw2GItsrq3z7O5dDc3prjLohjdRBY28qxki2a66Sivh9CwA+4lYsuEIsPvQVx hMZeNOUH9unaFfkdSVJhJnnovbqJ/gYPOudjYz/ao/wqWyeve+BpJZrDaWJu6IBLSV37EC WDThkpWIv2RXlhTRSRpcn/yTlO+3ipcY5xTwiBOGPLIRQYGmEo9dkpsni2Px/8sxiDtAb4 0aUj01NcCk/Ef8K/+RMIF9j8WBbX99sLvgj4R5losqDA1nLh6doabPlmRagpL5Cy5D3H3m hqwi68K1CGRbGeTEyBkanXwPBL9Q2R1DnwcexX9EcFYFEu4KfjTGbp7TKkkduA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=VS0bOcKC; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.03 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=VS0bOcKC; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 684E11C6B3 X-Spam-Score: -2.03 X-Migadu-Scanner: scn1.migadu.com X-TUID: d1IsPOxc4GGo Hi, Am Montag, dem 31.01.2022 um 23:19 -0500 schrieb Maxim Cournoyer: > * gnu/services/sound.scm () > [extra-script-files]: Add field. > (extra-script-files->file-union): Add procedure. > (pulseaudio-etc): Use it. > * doc/guix.texi: Document it. > --- >  doc/guix.texi          | 27 +++++++++++++++++++++++++++ >  gnu/services/sound.scm | 19 +++++++++++++++++-- >  2 files changed, 44 insertions(+), 2 deletions(-) > > diff --git a/doc/guix.texi b/doc/guix.texi > index a002670030..2f8df03461 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -21393,9 +21393,36 @@ List of settings to set in > @file{daemon.conf}, formatted just like >  @item @code{script-file} (default: @code{(file-append pulseaudio > "/etc/pulse/default.pa")}) >  Script file to use as @file{default.pa}. >   > +@item @code{extra-script-files} (default: @code{'())}) > +A list of file-like objects defining extra PulseAudio scripts to run > at > +the initialization of the @command{pulseaudio} daemon.  For a > reference > +of the available commands, refer to @command{man pulse-cli-syntax}. > + >  @item @code{system-script-file} (default: @code{(file-append > pulseaudio "/etc/pulse/system.pa")}) >  Script file to use as @file{system.pa}. >  @end table > + > +The example below sets the default PulseAudio card profile, the > default > +sink and the default source to use for a old SoundBlaster Audigy > sound > +card: > +@lisp > +(pulseaudio-configuration > + (extra-script-files > +  (list (plain-file "configure-audigy-card" > +                    (string-append "\ > +set-card-profile alsa_card.pci-0000_01_01.0 \ > +  output:analog-surround-40+input:analog-mono > +set-default-source alsa_input.pci-0000_01_01.0.analog-mono > +set-default-sink alsa_output.pci-0000_01_01.0.analog-surround- > 40\n"))))) > +@end lisp > + > +Note that @code{pulseaudio-service-type} is part of > +@code{%desktop-services}; if your operating system declaration was > +derived from one of the desktop templates, you'll want to adjust the > +above example to modify the existing @code{pulseaudio-service-type} > via > +@code{modify-services} (@pxref{Service Reference, > +@code{modify-services}}), instead of defining a new one. > + >  @end deftp >   >  @deffn {Scheme Variable} ladspa-service-type > diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm > index 19eccfc860..f529188a7c 100644 > --- a/gnu/services/sound.scm > +++ b/gnu/services/sound.scm > @@ -34,6 +34,7 @@ (define-module (gnu services sound) >    #:use-module (gnu packages linux) >    #:use-module (gnu packages pulseaudio) >    #:use-module (ice-9 match) > +  #:use-module (srfi srfi-1) >    #:export (alsa-configuration >              alsa-service-type >   > @@ -125,6 +126,8 @@ (define-record-type* >                 (default '((flat-volumes . no)))) >    (script-file pulseaudio-configuration-script-file >                 (default (file-append pulseaudio > "/etc/pulse/default.pa"))) > +  (extra-script-files pulseaudio-configuration-extra-script-files > +                      (default '())) >    (system-script-file pulseaudio-configuration-system-script-file >                        (default >                          (file-append pulseaudio > "/etc/pulse/system.pa")))) > @@ -145,14 +148,26 @@ (define pulseaudio-environment >         ("PULSE_CLIENTCONFIG" . ,(apply mixed-text-file "client.conf" >                                         (map pulseaudio-conf-entry > client-conf))))))) >   > +(define (extra-script-files->file-union extra-script-files) > +  "Return a G-exp obtained by processing EXTRA-SCRIPT-FILES with > FILE-UNION. > +Each file is named \"snippet-n.pa\", where N is their 1-offset > index." > +  (let ((labels (map (lambda (n) (format #f "snippet-~a.pa" n)) > +                     (iota (length extra-script-files) 1)))) > +    (file-union "default.pa.d" (zip labels extra-script-files)))) > + >  (define pulseaudio-etc >    (match-lambda > -    (($ _ _ default-script-file system- > script-file) > +    (($ _ _ default-script-file extra- > script-files > +                                   system-script-file) >       `(("pulse" >          ,(file-union >            "pulse" >            `(("default.pa" ,default-script-file) > -            ("system.pa" ,system-script-file)))))))) > +            ("system.pa" ,system-script-file) > +            ,@(if (null? extra-script-files) > +                  '() > +                  `(("default.pa.d" ,(extra-script-files->file-union > +                                      extra-script-files))))))))))) >   >  (define pulseaudio-service-type >    (service-type Is there a particular use-case for this (other than working around the location issue of default.pa et al.)? If not, I'd rather make it s.t. our other files can more easily be stitched together in-place. Also, assuming that we're using file-like objects here, I think we should use the store name minus prefix and hash for the file name. E.g. if Alice adds soundblaster.pa, it'd make sense to label it soundblaster.pa, so that changes to snippet order don't mess up any configuration referring to those files. Cheers