From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iLi9EMqA/2G9EgEAgWs5BA (envelope-from ) for ; Sun, 06 Feb 2022 09:03:22 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id gLspDsqA/2F4YwEA9RJhRA (envelope-from ) for ; Sun, 06 Feb 2022 09:03:22 +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 DA4F8E255 for ; Sun, 6 Feb 2022 09:03:21 +0100 (CET) Received: from localhost ([::1]:41576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGcW0-0003iv-2U for larch@yhetil.org; Sun, 06 Feb 2022 03:03:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGcVi-0003gt-M8 for guix-patches@gnu.org; Sun, 06 Feb 2022 03:03:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:42398) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGcVi-0008B8-5z for guix-patches@gnu.org; Sun, 06 Feb 2022 03:03:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nGcVi-0006hh-0J for guix-patches@gnu.org; Sun, 06 Feb 2022 03:03:02 -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: Sun, 06 Feb 2022 08:03: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 Cc: 53676@debbugs.gnu.org Received: via spool by 53676-submit@debbugs.gnu.org id=B53676.164413455125733 (code B ref 53676); Sun, 06 Feb 2022 08:03:01 +0000 Received: (at 53676) by debbugs.gnu.org; 6 Feb 2022 08:02:31 +0000 Received: from localhost ([127.0.0.1]:36295 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGcVD-0006gz-FN for submit@debbugs.gnu.org; Sun, 06 Feb 2022 03:02:31 -0500 Received: from mail-ej1-f68.google.com ([209.85.218.68]:42878) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGcVC-0006gm-4P for 53676@debbugs.gnu.org; Sun, 06 Feb 2022 03:02:30 -0500 Received: by mail-ej1-f68.google.com with SMTP id m4so33064307ejb.9 for <53676@debbugs.gnu.org>; Sun, 06 Feb 2022 00:02:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=rfQr+QcPmuaCAx+T5ndQG6iPEmXxKBijM29ZTUm3FJA=; b=WP5b6xRE//ZzQ6uIa0dWNd3VDqt4irOvmt+oDTHXjALkPv0apTMrzRjC1ZzDEcIait ViqHSKDYRX1UJdhfpdos/D4L7eez022RjPduepPiiPXTka9Q0y7z7T0uutc3woz0tP0I YhruYkhVeh3BT9OVmMFmEPwao9QKc3bBIgvS1s5nb41bOqhxmMTGS5i5vfThqrhgzYY7 1gafqGDI/nN7Jigz4M8/Cp0qQnEvg6Rmi+xw2OWKZ0NJkI37RDA/PpjHOSCzV4Mx+nbV +iBeaZ5K+Gf/RcWvmzhv2dLIn/etcfgKlEEwgA3a9ggFlKXnOimdq+i928j88NiatqTI N8sQ== 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:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=rfQr+QcPmuaCAx+T5ndQG6iPEmXxKBijM29ZTUm3FJA=; b=Rv/iq8r3Ui5lyMtNzZvJuDKJOm514sVRc/vZmB7tp3eFgS8XqPFjXMAGYCcbtqIHYM in1kvV0ZSQvubTuTfLyS4ceVfYpVSuuUKHFvx6aBAAh6/Kb6jWARtso3cA4vO+JOMefx gk4Y0Ukq09xmLhDR5y8fLphd/F6ysCtoq3KlBu9Cbog2lC940yUKqu9RBeDExELztCQN mF+aDfT51YDt+yNoql4vY0/YiVrBoGZRt1yX8NUVgw19KHZNo9Ln4tWuI0PoBXoG4GhA GTFdVzbXPtfkqIbWPD7TbCf51+lBc1ZzrJ5tAg0/jZrKx+e0iFdDk3NVW9BrHdItCNzC Pp6A== X-Gm-Message-State: AOAM533Vp56Bgp6zCI6bMRZoze/j8pInVo3rZrJhrl7CxJYPtrfZbIt2 LrcelWXd5Xgv6oruRMEnBrA= X-Google-Smtp-Source: ABdhPJwtgk6Qk7YKZAMn23AsVLDmFWvP0VUv2JRNNF20A4BvrVkz679jlgIQud5bGQ8jihRaxSshOA== X-Received: by 2002:a17:907:7e92:: with SMTP id qb18mr5796389ejc.555.1644134543985; Sun, 06 Feb 2022 00:02:23 -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 fw6sm1052979ejc.143.2022.02.06.00.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 00:02:23 -0800 (PST) Message-ID: From: Liliana Marie Prikler Date: Sun, 06 Feb 2022 09:02:22 +0100 In-Reply-To: <87czk01mp8.fsf@gmail.com> References: <20220201041933.16603-1-maxim.cournoyer@gmail.com> <20220201041933.16603-4-maxim.cournoyer@gmail.com> <97111754acacc576aec4eb55889a32474fe71f95.camel@gmail.com> <871r0m1gdy.fsf@gmail.com> <3c9845d7b893dddcd44be41d2ee475c29d9f5a85.camel@gmail.com> <87o83qyltg.fsf@gmail.com> <2b8017576ee2570fd38ab61729556e31694b2552.camel@gmail.com> <87czk01mp8.fsf@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=1644134602; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=rfQr+QcPmuaCAx+T5ndQG6iPEmXxKBijM29ZTUm3FJA=; b=EZ02tOkTfYjTce1xygGUjDSmTt+BLIMPFAsgemtGWQfFNk/wJV3mkzzKZGYrcss1Jf9Vc4 UnsinEMKMxOI8QZAFPrqK1lSOgshe8HVk/QQMkI2zPB+RR1U8DfH5n1TmiMLuCJ2PJJj7O 1rA6w5Puz669P7Q6wENHKijqpOWtx10opSaLesZVjrYczPixyQqxYeJt70xU8kbwAZUDJj TS8QmtKduip0SS2m2o638aENr950wgj7ihjhXosMtm6Y9AyLKrJXJr8v38RJt34WbgpaR8 CabglsHnRsEhYoAVEzJOpefuUhWat7ux2pRcvQK52jPZAc3Hpcv/7Ho1EtEGFA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644134602; a=rsa-sha256; cv=none; b=n51R/vCQDiE9x++W0f14gAznvHIDviRaq31+y68cr92mGjPUEhrmQpnYBVu/XEC4qvNSiN /+X6OQeB5eNN+H30QD4zabbhbT/Vjy6TBEgh3TEs+nM3yFuISEvGcEgGHcwn3Qi3PlETre ++3XTNnUf6omEWUwcR0C4+1zqe35Buvq5NewNoWuFzPXeVR7gB1iv9yfkzRLTRdNwxX6MY Zqw7luMPVUMzln8/Of/jimbTwAJZ6NbMnXZ75Xs5E8JGOm/m2oOd9aH5H6/JB7O5Qtho4Z Gt+b5esXYrjOsxndZnP6dKo8C1YowDTDryto2Zicq85l9GwvykZOsGkf7iSsKQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=WP5b6xRE; 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: -3.03 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=WP5b6xRE; 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: DA4F8E255 X-Spam-Score: -3.03 X-Migadu-Scanner: scn0.migadu.com X-TUID: Ob2OHpyDvB8n Hi Maxim, Am Sonntag, dem 06.02.2022 um 02:25 -0500 schrieb Maxim Cournoyer: > Hi Liliana, > > [...] > > > > 'strip-store-file-name' would be able to get the name from the > > > store > > > item (built derivation), but file-union takes a "two-element list > > > where the first element is the file name to use in the new > > > directory, > > > and the second element is a gexp denoting the target file", e.g., > > > before the file-like object is built.  I don't see an easy way to > > > make it work. > > For the record, I do think we'd like to use file-like objects here, > > not > > raw gexps.  If that fails, why not expose the name to gexp mapping > > completely?  I don't know why you'd want to take away that control. > > If we limit ourselves to file-like objects, we can do something like > this: > > --8<---------------cut here---------------start------------->8--- > 1 file changed, 20 insertions(+), 4 deletions(-) > gnu/services/sound.scm | 24 ++++++++++++++++++++---- > > modified   gnu/services/sound.scm > @@ -26,10 +26,12 @@ (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) > @@ -149,10 +151,24 @@ (define pulseaudio-environment >         ("PULSE_CLIENTCONFIG" . "/etc/pulse/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)))) > +  "Return a G-exp obtained by processing EXTRA-SCRIPT-FILES with FILE- > UNION." > + > +  (define (file-like->name file) > +    (let ((name (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))))) > +      (unless (string-suffix? name ".pa") > +        (leave (G_ "`~a' lacks the required '.pa' file name > extension~%") > +               name)) > +      name)) > + > +  (let ((labels (map file-like->name extra-script-files))) >      (file-union "default.pa.d" (zip labels extra-script-files)))) >   >  (define pulseaudio-etc > --8<---------------cut here---------------end--------------->8--- > > It works; and I agree it's nice to have control over the file name. Note that file-like->name serves multiple duties here. In my opinion it'd be better to --8<---------------cut here---------------start------------->8--- (define (file-like-name file) ((match file ((? local-file?) local-file-name)  ((? plain-file?) plain-file-name)  ((? computed-file?) computed-file-name) [...] (_ (const #f))) ; alternatively raise an error file)) --8<---------------cut here---------------end--------------->8--- That at least decouples it from the burden of having to check whether it is a valid pulseaudio script file name, which makes it reusable elsewhere. As a note regarding correctness, perhaps we should write an implementation in (guix gexp) that works for everything that has a gexp-compiler, but that's out of scope for now. On the pulseaudio side, you'd compose that with an --8<---------------cut here---------------start------------->8--- (define (assert-pulseaudio-script-file-name name) (unless name (raise ...)) (unless (string-suffix? name ".pa") (leave ...)) name) --8<---------------cut here---------------end--------------->8--- Cheers