From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id ELipBpumWGGaCQAAgWs5BA (envelope-from ) for ; Sat, 02 Oct 2021 20:36:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 2JBTApumWGFDHAAA1q6Kng (envelope-from ) for ; Sat, 02 Oct 2021 18:36:11 +0000 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 686133426F for ; Sat, 2 Oct 2021 20:36:10 +0200 (CEST) Received: from localhost ([::1]:57536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWjrl-0005cC-It for larch@yhetil.org; Sat, 02 Oct 2021 14:36:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWjre-0005bQ-Bk for guix-patches@gnu.org; Sat, 02 Oct 2021 14:36:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49007) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWjre-00072T-2i for guix-patches@gnu.org; Sat, 02 Oct 2021 14:36:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mWjrd-0007L5-SM for guix-patches@gnu.org; Sat, 02 Oct 2021 14:36:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 02 Oct 2021 18:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50967 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Oleg Pykhalov , 50967@debbugs.gnu.org Cc: Oleg Pykhalov Received: via spool by 50967-submit@debbugs.gnu.org id=B50967.163319975228186 (code B ref 50967); Sat, 02 Oct 2021 18:36:01 +0000 Received: (at 50967) by debbugs.gnu.org; 2 Oct 2021 18:35:52 +0000 Received: from localhost ([127.0.0.1]:60553 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWjrU-0007KY-C6 for submit@debbugs.gnu.org; Sat, 02 Oct 2021 14:35:52 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:39384 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWjrR-0007K6-V5 for 50967@debbugs.gnu.org; Sat, 02 Oct 2021 14:35:50 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1633199742; bh=rxd+yKk+N3AIICAz9O9P2oEG7KL1Yo+h47VX1c4ju8E=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=oxufv237PTb8dSAajkQUYyS5NQOHn+3KGRMHwqBqSsUhZIDBxp/j8juVMVXJA4pMk /P9jJd0PmsNHnjOUtnOjdbEWifwCg9WrbpAQqJS1do+8PrEb68he0/jzQr717Vw0N6 hmbIR5s2oXzVaoNX4UXnlFa8qJ77P9/AN0d+t6YA= In-Reply-To: <20211002163834.29583-13-go.wigust@gmail.com> References: <20211002163834.29583-1-go.wigust@gmail.com> <20211002163834.29583-13-go.wigust@gmail.com> Date: Sat, 02 Oct 2021 20:35:40 +0200 Message-ID: <87pmsnnukj.fsf@yoctocell.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1633199770; 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: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=2aAPU/wyH+Pgm6sDV9nwOiCpSoYqs/70ArTEIGqtaDM=; b=PpG1Xliu9emMPYSYQjhxI8hce+s8OiLpJZiUbvmcNA/PF9m27YwIC+nsmFB2HPAPclO21F 8c6zMltQAMhSuYaPQIf+/wKMalx6n3aBAaPDQFxOaMJyx5DjorIdkAid1e1nSCmQP4PMHD +YlR4Xpll16L3hN18ZbCZgxFusoUcYn2PjP1O+e0RW7/28qOPBC15BSriN9FY7gf7mZmU+ 4IrqoOtMaRb8GKI/jzyFfn4qwnSNlLXyccVuNzbJmzC8N+eYiMNj9yfmDtrbwzUtMgFXG3 GPw8LWMkGqV9691kOSb8QIDpocMI+ylx8SnV/gxkd8Avb1tM3yP1hpfX3/7hjg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633199770; a=rsa-sha256; cv=none; b=fqgiu+D6ME9Li5fEMIw/QxJsLvK1t/QeiR0kybQMNJ1CAvUX0fdzJFxQwrzlU4cHI+5jn8 SIeuS2g6ln5G/Fja+upYduMccrOnElTPaSWi2ukMzBzRdcGPUT9wh4HrvU67Z3OP0VZiHi EmmWIZhYECF2Os/wRFkzcL6ehMyNfry0HGwgq1LdIabyolfp4M3DMnQlsejG3ErtJCnFLQ Z3mw1YXg6RXmI8JwfOtjMjJEn3cs6zLWQSIAC3a7oLyHpQd9jfq4WvZEuRFNGk5NvCr1Wz xdZ3jGVMGuBKdQeRQoGbM5y+WG/tjD9HLLhkTVxxPtcJOKc5nyYpOVRAfgUhAA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=oxufv237; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -3.81 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=oxufv237; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yoctocell.xyz (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 686133426F X-Spam-Score: -3.81 X-Migadu-Scanner: scn1.migadu.com X-TUID: Pl3u7DeHcE7G --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sat, Oct 02 2021, Oleg Pykhalov wrote: > * gnu/home/services/configuration.scm (interpose): Include content of fil= es. > (string-or-gexp?): Rename to 'file-or-string-or-gexp?' and check for file= -like > object. I would call it =E2=80=98file-like-or-string-or-gexp?=E2=80=99, just =E2=80= =98files=E2=80=99 doesn=E2=80=99t really make it clear that it should be a =E2=80=9Cfile-like object=E2=80=9D. > (serialize-string-or-gexp): Rename to 'serialize-file-or-string-or-gexp'. > (text-config?): Call 'file-or-string-or-gexp?' intead of 'string-or-gexp?= '. > * guix/scripts/home/import.scm: > (generate-bash-module+configuration): Don't call slurp-file-gexp. > --- > gnu/home/services/configuration.scm | 14 ++++++++++---- > guix/scripts/home/import.scm | 8 +++----- > 2 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/gnu/home/services/configuration.scm b/gnu/home/services/conf= iguration.scm > index 5e7743e7d6..39db7a5693 100644 > --- a/gnu/home/services/configuration.scm > +++ b/gnu/home/services/configuration.scm > @@ -59,7 +59,12 @@ DELIMITER interposed LS. Support 'infix and 'suffix G= RAMMAR values." > (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.= ") > grammar))) > (fold-right (lambda (e acc) > - (cons e > + (cons (if (file-like? e) > + #~(begin > + (use-modules (ice-9 rdelim)) > + (with-fluids ((%default-port-encoding "UTF= -8")) > + (with-input-from-file #$e read-string))) > + e) > (if (and (null? acc) (eq? grammar 'infix)) > acc > (cons delimiter acc)))) > @@ -79,11 +84,12 @@ the list result in @code{#t} when applying PRED? on t= hem." >=20=20 > (define alist? list?) >=20=20 > -(define (string-or-gexp? sg) (or (string? sg) (gexp? sg))) > -(define (serialize-string-or-gexp field-name val) "") > +(define (file-or-string-or-gexp? fsg) > + (or (string? fsg) (gexp? fsg) (file-like? fsg))) > +(define (serialize-file-or-string-or-gexp field-name val) "") This could defined as =E2=80=98empty-serializer=E2=80=99 from (gnu services configuration). >=20=20 > (define (text-config? config) > - (and (list? config) (every string-or-gexp? config))) > + (and (list? config) (every file-or-string-or-gexp? config))) =E2=80=98text-config?=E2=80=99 could be defined as (list-of file-or-string-= or-gexp?) > (define (serialize-text-config field-name val) > #~(string-append #$@(interpose val "\n" 'suffix))) >=20=20 > diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm > index c977ec3861..611f580e85 100644 > --- a/guix/scripts/home/import.scm > +++ b/guix/scripts/home/import.scm > @@ -46,17 +46,15 @@ > (home-bash-configuration > ,@(if (file-exists? rc) > `((bashrc > - (list (slurp-file-gexp (local-file ,rc))))) > + (list (local-file ,rc)))) > '()) > ,@(if (file-exists? profile) > `((bash-profile > - (list (slurp-file-gexp > - (local-file ,profile))))) > + (list (local-file ,profile)))) > '()) > ,@(if (file-exists? logout) > `((bash-logout > - (list (slurp-file-gexp > - (local-file ,logout))))) > + (list (local-file ,logout)))) > '())))))) >=20=20 >=20=20 > --=20 > 2.33.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmFYpnwVHHB1YmxpY0B5 b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x56r4P/0E3sjdTwEFvKzLyUbKzrOiJ0oDS hbIR60OeZvwObum5nTBtsgPuQSdyV5tM/owT3CTEPAF23OukIQfqNA4w4SiOa12f QEDhw8rqQzis1DTowJ2/Tq0wWhTugJEmhJvZ9w3Nyg4cM8UT7GWYY9XVkluwKX3z 8OVITAkSzMh+sA3P+cTSoEjy6K4I/xNlnnbropn5SEwK+q95DlD5Uz0CBDhPTPPt GOQuO2PRIQsMMKT4L/FTaieZql+7bedD4xCotuBsGgYDmfKasFm0z4P2B/vGDzb8 ef0byxg3NbdX8lrzt3g+MtwIRWXY7IJxmFdplGhNbASAKHSlb1alqdgYGW/2CWeT c94QD77itFURRkI3S4nm5Ukeh+nNfSwM9tDY4koo905R/QgJvS2FQhJgnOuD+hqI 73VTuCTtTIxpPKMP6exhBd8wPCioFlW+CceTVljh+MHwGbVlgeqYDOKBTXXihDrO UFxzGNoM0XG6xECA2z3ZBRplDd6az2XWxekYtEgWoCD6iYRPvHrm6CR12HkLKQZv LN+uidEyT2aVa8G0wJ/MJlE+ff0S4ck4fh7Cwfn2KePAss07KOcLsybjEchpyCEQ huj/IczfOS8Tcv7o1WMR0hL70cb2aV/3n5pkSNwAR4G18cbEmO01A3ABNLS1KXaU neMyfiIH7o+2qZqY =Y9dG -----END PGP SIGNATURE----- --=-=-=--