From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id CIiXDwa1F2KwggEAgWs5BA (envelope-from ) for ; Thu, 24 Feb 2022 17:40:38 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id uPM4DAa1F2IbwwAAauVa8A (envelope-from ) for ; Thu, 24 Feb 2022 17:40:38 +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 7EDCC37829 for ; Thu, 24 Feb 2022 17:40:37 +0100 (CET) Received: from localhost ([::1]:40916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNHAS-00070I-Mf for larch@yhetil.org; Thu, 24 Feb 2022 11:40:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNH9v-0006Xa-Re for guix-patches@gnu.org; Thu, 24 Feb 2022 11:40:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:56361) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nNH9u-0000LN-PY for guix-patches@gnu.org; Thu, 24 Feb 2022 11:40:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nNH9u-0002rD-Nh for guix-patches@gnu.org; Thu, 24 Feb 2022 11:40:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53676] [PATCH v2 3/4] services: pulseaudio: Add an extra-script-files configuration field. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 24 Feb 2022 16:40:02 +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: 53676@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 53676-submit@debbugs.gnu.org id=B53676.164572075810903 (code B ref 53676); Thu, 24 Feb 2022 16:40:02 +0000 Received: (at 53676) by debbugs.gnu.org; 24 Feb 2022 16:39:18 +0000 Received: from localhost ([127.0.0.1]:50253 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nNH9C-0002pm-B6 for submit@debbugs.gnu.org; Thu, 24 Feb 2022 11:39:18 -0500 Received: from mail-qv1-f41.google.com ([209.85.219.41]:46790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nNH9A-0002pM-Cj for 53676@debbugs.gnu.org; Thu, 24 Feb 2022 11:39:16 -0500 Received: by mail-qv1-f41.google.com with SMTP id j5so4488113qvs.13 for <53676@debbugs.gnu.org>; Thu, 24 Feb 2022 08:39:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=//0UcyvMykC0klOPtwtR6f4nL79ZAGy3oAQCvAhj/kI=; b=I/ZQ0FwbwuV0Ull++DL9p/5s3dI0ZTljma3us9FVW8OvNL3hMBFR2cPFMJIXv7bXVg kzQNNcGby3Mc3alGT1kK8xjt3wj7r/iZHkbR0Ptg54/lc/cJ37PavSX2YTWYnN7yj8Mn rCBdDryVOo9/9FW0nX2MQFV4aNjVxYkNmfjqWMRxqq07wykMoFB80LBOO826OsLOntXS SPd9EKhmna/ida0zcWQ6g/rIb7jOl9mHUOpF45RHigdtkfwGGwf6GcXV7M2D76jgO4mO KZKla0XpuKNxp+Pn3JT/IXVV11WT4DsR55E2NhSBPWAKdaWq4RL6VqrckXrlQPKZCuKY L0pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=//0UcyvMykC0klOPtwtR6f4nL79ZAGy3oAQCvAhj/kI=; b=vPI4PsD4qVGAeHeCQQk6QVynBTgqayt+VWP2NDMB9EMS+4iCIhQa5WSCxDlbCtF2hr HqaXTBeABpFkgfu9SnEVRAJWptHsLzxi2E+3YsHi6Cx1+U3CxDzIamkpb7udQ+tt1DoK wpXSQB8szOVZnVGFUhpa6JLKqow9WKMd43dD9DCBjEUNIauJOYIWu0CFkO+CAyPcnGf+ j/5ni7eHHd7KLA+h2j9M5OQW845pw5RocQKx3am3jGNB11CpzWR5Oz1Maw7J5lmZBSR5 5CD+ZjS4VEoYm0wpbQGAJ3zzTO9Vsd+DSJ4XSJQVhS9sMC0ZsTUlPmlTT2sqP2jxOuA5 u+9Q== X-Gm-Message-State: AOAM5300me/53JUrjV0Re6kJrqNynZTCVJ73NUuZEzpXziOpgmP0MXhW nmHTtk04rd7o+XmbgsrobKkPeuKZi4vDwQ== X-Google-Smtp-Source: ABdhPJyb/PEQ2hJAC13Ws7nhbFpL6JuSDWdxZa41qq197+saUqU1oz4T+w6OXEfeJYDHmJYyNK4RnA== X-Received: by 2002:ac8:5648:0:b0:2ce:dd03:59fa with SMTP id 8-20020ac85648000000b002cedd0359famr3163046qtt.288.1645720750579; Thu, 24 Feb 2022 08:39:10 -0800 (PST) Received: from localhost.localdomain (dsl-156-1.b2b2c.ca. [66.158.156.1]) by smtp.gmail.com with ESMTPSA id b13sm1900956qtb.71.2022.02.24.08.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 08:39:10 -0800 (PST) From: Maxim Cournoyer Date: Thu, 24 Feb 2022 11:38:27 -0500 Message-Id: <20220224163828.11330-3-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220224163828.11330-1-maxim.cournoyer@gmail.com> References: <20220224163828.11330-1-maxim.cournoyer@gmail.com> 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=1645720837; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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=//0UcyvMykC0klOPtwtR6f4nL79ZAGy3oAQCvAhj/kI=; b=QfUEc1MWU1aE+oORsYMpbWXPPY0LinMYpnBZRxdH1szN0S5yGliHKVVythg7mz1USzLkJz /nqR6lxbEXhAZVrRkQYUIPvW+gEi3WxX63eIFKL69aWlwKzmziKrivGUMBMMMiFrBIaIcW u5P1xcJHRG25cCUzr0WZs3qs1CLzAnIHWPfJq+6tK7iOqQJHAFnqRP34Hc7TsC10JrxTwZ gCOKcXC5YHmsC5sfZjkUQ3oiBdvH0zNCVfOczoRUxPjcSUCMXpaca4GEloE129GW92i7kq MGtvhJZWhkTo8wnY/mFXy9dUklPNHlMUwe3Deepr7vhAoptgBBCCNU7LAkYeGA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1645720837; a=rsa-sha256; cv=none; b=oKBLaRqrRBV/i+hkvtAypcAnG8MWtRaTAHqQR7KQp0wWO7DJ2xZYd0U8slGoaLJp1DQ0uY 8PDoKKu923GC9+k+vzDvq/eL0PKU1nuQKAUWbr4UyRh9uChZyCAXNAapLb8BRuzRrxtJb6 eKoKmDcXC0/jQJH9qaRWmPAK2+LTW/xnQ+wHtmY0rSb21DqXYCF2iYaBm2G6yrsgcZufP+ wasdej05+Rzm31FThLqRLmoeYih3bZ4JiryB7WrrUdCoRxc2FbZPZgLMG6JYXQddV8ZoJ2 9hFVqsdRcUGhYAhpQ8ms2g/BPooJmpOghoCW9uZdqFvi9vmV7TkJdmFfZATfrw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="I/ZQ0Fwb"; 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: -1.53 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="I/ZQ0Fwb"; 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: 7EDCC37829 X-Spam-Score: -1.53 X-Migadu-Scanner: scn1.migadu.com X-TUID: mOiACAcobk+0 * 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 | 30 ++++++++++++++++++++++++++++++ gnu/services/sound.scm | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index f336c26e8a..9941be5033 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -21509,9 +21509,39 @@ 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, after the main +@code{script-file}. The scripts are deployed to the +@file{/etc/pulse/default.pa.d} directory; they should have the +@samp{.pa} file name extension. 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 "audigy.pa" + (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 9684e06d13..eecea1a733 100644 --- a/gnu/services/sound.scm +++ b/gnu/services/sound.scm @@ -26,14 +26,17 @@ (define-module (gnu services sound) #:use-module (gnu services) #:use-module (gnu system pam) #:use-module (gnu system shadow) + #:use-module (guix diagnostics) #:use-module (guix gexp) #:use-module (guix packages) #:use-module (guix records) #:use-module (guix store) + #:use-module (guix ui) #:use-module (gnu packages audio) #: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 +128,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 +150,43 @@ (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." + + (define (file-like->name file) + (match file + ((? local-file?) + (local-file-name file)) + ((? plain-file?) + (plain-file-name file)) + ((? computed-file?) + (computed-file-name file)) + (_ (leave (G_ "~a is not a local-file, plain-file or \ +computed-file object~%") file)))) + + (define (assert-pulseaudio-script-file-name name) + (unless (string-suffix? ".pa" name) + (leave (G_ "`~a' lacks the required `.pa' file name extension~%") name)) + name) + + (let ((labels (map (compose assert-pulseaudio-script-file-name + file-like->name) + extra-script-files))) + (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 -- 2.34.0