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 MLZPM/5NYGGYTAEAgWs5BA (envelope-from ) for ; Fri, 08 Oct 2021 15:56:14 +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 0JknLf5NYGEwbgAA1q6Kng (envelope-from ) for ; Fri, 08 Oct 2021 13:56:14 +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 3AFE12B724 for ; Fri, 8 Oct 2021 15:56:14 +0200 (CEST) Received: from localhost ([::1]:60910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYqM9-000053-BC for larch@yhetil.org; Fri, 08 Oct 2021 09:56:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYqDG-0001QI-52 for guix-patches@gnu.org; Fri, 08 Oct 2021 09:47:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:37944) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mYqDF-0000gy-Rd for guix-patches@gnu.org; Fri, 08 Oct 2021 09:47:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mYqDF-0004Dv-Kb for guix-patches@gnu.org; Fri, 08 Oct 2021 09:47:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50967] file-like objects instead of gexps Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 08 Oct 2021 13:47: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: Andrew Tropin , Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: Oleg Pykhalov , 50967@debbugs.gnu.org Received: via spool by 50967-submit@debbugs.gnu.org id=B50967.163370077016176 (code B ref 50967); Fri, 08 Oct 2021 13:47:01 +0000 Received: (at 50967) by debbugs.gnu.org; 8 Oct 2021 13:46:10 +0000 Received: from localhost ([127.0.0.1]:49490 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mYqCP-0004Cp-F8 for submit@debbugs.gnu.org; Fri, 08 Oct 2021 09:46:09 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:39974 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mYqCJ-0004C0-O1 for 50967@debbugs.gnu.org; Fri, 08 Oct 2021 09:46:08 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1633700755; bh=CYBhX5N2ym/okJMqQfFUsc+zIXb4XGmKTYv65Y3bAHU=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=kXI7MfosXqeCKsAyOYr/qI9twOQ3g7qwWcRhv8+5hYFGexGDMzdHQ1DAEwLESLbdy lR05+r9aS5pogkPreVjFUGLHkvykdQAnjoFttfIaQgM6RgT69q/RiPpBcw2XFgisIg BAGNbePrimHv3kI4rzkOXm7EX5r72IKyTA5frMlM= In-Reply-To: <87czoilgbg.fsf@trop.in> References: <20211002163834.29583-1-go.wigust@gmail.com> <20211002163834.29583-13-go.wigust@gmail.com> <87pmsnnukj.fsf@yoctocell.xyz> <878rz8q42z.fsf_-_@gnu.org> <87czoilgbg.fsf@trop.in> Date: Fri, 08 Oct 2021 15:45:51 +0200 Message-ID: <87ee8vmxyo.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=1633701374; 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=TL2UubijMTyNSBC2WUhgK/r2FZDuQpiQ3bmhQSHICP8=; b=ZEzyF2XZN9owp4xfGw1Z5SJnJFCeTP0f0oQM6xqnU8Hv7e/v/fF8papxmWDXUY/2s7eM3b HvfRI29JMQFnGz82UftESXDcBNM5UYpAjkSDgIrdkiVqFBDOaVMnIxO2Knozn9rHNethIJ g2vUlCP1fEp+FS3BuM0EfPAxf6Nxpz6PKPbhLcYfNoDDmM1k9O7c7u0RMUXWd6vUa9hDLh WFCnHqqzSQgbolq6xr8XgOKo0Nxs5CJ0tuAG50jzsyOGpWlXQTGXag7HzaTJC8Igp2rzQs NC4repZA1Jkd3J1UKYTXU5rPNXp9BDjpAW+6hKiIu8/SLycNYHvVCjfGxGg8PA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633701374; a=rsa-sha256; cv=none; b=QyEhi2ecGIfuo3CUGeKwVfbar0ikBeZewuccV5vRr5M+dcf77EIxZkUaO17f48sjz4MG8y Fr5k4eEGZLtFXH4ZtTMQlERHfWnd+8Hp1G06YsRQGzdhln5Ob/fLClpMxkxwwMWNZ7IRgs BQkZdpbfgeYIXTvyFEmVrGqcOALBjPXpFtwDsnHv/zm7YfxDCPNaVYmFg7fps0STY2VSuN 3Shos7imcQGgcMpJyJb8BLBf/sDXsQ44u/B6Fa6dZTowX885ZJnp5dzYBYABwPnkWnb3Wh qMXTiWKPI1bt5bt5686C3vXTfn8g6Qqx3fBvfoJ8MsrIfjohhHLZDGav/j0gFQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=kXI7Mfos; 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-Spam-Score: -0.41 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=kXI7Mfos; 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: 3AFE12B724 X-Spam-Score: -0.41 X-Migadu-Scanner: scn0.migadu.com X-TUID: mLOl18gAKsRK --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Oct 06 2021, Andrew Tropin wrote: > Imagine the following use case: I want to create a home service, which > accepts a package (zsh plugin) and adds a code for loading this package > to zshrc, currently it's implemented like that: > > https://git.sr.ht/~abcdw/rde/tree/69dd2baf0384c899a4a4f97bdac8bf0b6e499b8= 2/item/gnu/home-services/shellutils.scm#L18 > > Exteding the service above with `(list zsh-autosuggestions)` will add > the following line to zshrc: > > source /gnu/store/w7d43gk1qszplj9i0rkzqvzz6kp88qfm-zsh-autosuggestions-0.= 7.0/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh > > Or the same thing can be done manually by user: > > --8<---------------cut here---------------start------------->8--- > (service > home-zsh-service-type > (home-zsh-configuration > (zshrc > (list > #~(string-append "source " #$zsh-autosuggestions "/share/zs../..ions.= zsh") > ;; or > "source \\" > (file-append zsh-autosuggestions "/share/zs../..ions.zsh"))))) > --8<---------------cut here---------------end--------------->8--- > > gexps returns a string, file-like object returns a path to the file in > the store, kinda expected behavior. Both implementations looks quite > simple. > > > Now I'll try to reimplement it with file-like objects. The code below > is a pseudo code, but should demonstrate the overall concerns I have: > > --8<---------------cut here---------------start------------->8--- > ;; Some generic functions > (define get-file-like-object-path (file-like) > "Because all file-like object get inserted literally by home services, > we need a function, which returns a file, which contains a path to the > file." > (computed-file > "tmp-file" > #~#$file-like)) > > (define fl-append-strings (lst) > "Accepts a list of strings and file-like object, reads the content of > the file-like objects (to be consistent with behavior of home services > configuration)." > (define file-like->str (mb-file-like) > (if (string? mb-file-like) > mb-file-like > #~(begin > (use-modules (ice-9 rdelim)) > (with-fluids ((%default-port-encoding "UTF-8")) > (with-input-from-file #$mb-file-like read-string))))) > (computed-file > "tmp-file" > #~(apply string-append '#$(map file-like->str lst)))) > > > ;; A home service, declared in home-environment. > (service > home-zsh-service-type > (home-zsh-configuration > (zshrc > (list > (fl-append-strings > (list > "source " > (get-file-like-object-path zsh-autosuggestions) > "/share/zs../..ions.zsh")) > ;; or > "source \\" > (get-file-like-object-path > (file-append zsh-autosuggestions "/share/zs../..ions.zsh")))))) > --8<---------------cut here---------------end--------------->8--- Wouldn=E2=80=99t something like the following work =2D-8<---------------cut here---------------start------------->8--- (service home-zsh-service-type (home-zsh-configuration (zshrc (list (mixed-text-file "zshrc" "source " (file-append zsh-autosuggestions "/share/zsh/...")) (local-file "./some-zshrc"))))) =2D-8<---------------cut here---------------end--------------->8--- and since =E2=80=98zshrc=E2=80=99 is already a list of file-like objects, w= e could implement =E2=80=98serialize-text-config=E2=80=99 using something like =E2=80=98fl-append-strings=E2=80=99, which would read the contents of the t= wo files and append them. That way users don=E2=80=99t have to deal with =E2=80=98fl-ap= pend-strings=E2=80=99 or =E2=80=98slurp-file-gexp=E2=80=99. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmFgS48VHHB1YmxpY0B5 b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5IegP/3N6sllx+97nIbG7lzoe0XMnm7XS 9BWteu3/4O51LgJtli5irkohFDUK1eBLIOxbCS1YRMkzcIPAZtKNJcglc3YMjo6m Bdwoa07uc9H4rehrzDX+e7DGRB8EW2EPfwupHR8I6Abzw7KAwpsYLqd8MB7Mzv6S CksV5lv6Dg7LxkRJ1kghrzCWo48Mpu+Y53aalrKYXgDkYTTIRirsgiOMCXJWXoXe B6KMJp0kJ92g10Q+acxwAs154HVeYQnHpXeKu8XJPFHrCKnTmD+fvro79+85hrp1 jbhHwMXioX8F5sCgfVmYI4/gNoUz/UhTtqZtq8cibZimlopm/5Iw1ss4lizV1TPi SCYgaMc4qMXxrHJoGS6hvkhjvZJdnuJNiyLRu+oIKyi3/YIGDBIdEubkiOlDD4u4 owteA1RULTi7xByMVe6t8FyPE3fOssSOBbTbyjzdHx6JIhJtyjkaMYuS+BtaYwRk 8NntbfftcPr+J1t4Yf9xNf26RmyTjXzWgzVcplUp9a0YVC6nwvW+NOcEYPqgZfX3 +wlGEiTxAd+YAzyK1WTZ1HOEJHSGmcM0TLWneZFtv0IpCKy8w/FS3ihJCxWdAyfe /8lNNry9+GNx/qwYXqqSfgIsDWyp0+iU0h97QE6LB/wl/dw6+r+RVmdBAuCuuLS4 O/4WgOwOu3L2odoc =4wZg -----END PGP SIGNATURE----- --=-=-=--