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 4FtqNhGSWGGhZwEAgWs5BA (envelope-from ) for ; Sat, 02 Oct 2021 19:08:33 +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 +LUfMhGSWGG9XQAA1q6Kng (envelope-from ) for ; Sat, 02 Oct 2021 17:08:33 +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 805E13350E for ; Sat, 2 Oct 2021 19:08:33 +0200 (CEST) Received: from localhost ([::1]:47962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWi4T-0003Og-Az for larch@yhetil.org; Sat, 02 Oct 2021 12:41:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWi3T-0002Is-92 for guix-patches@gnu.org; Sat, 02 Oct 2021 12:40:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWi3T-00032R-0P for guix-patches@gnu.org; Sat, 02 Oct 2021 12:40:07 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mWi3S-0008Ky-Ua for guix-patches@gnu.org; Sat, 02 Oct 2021 12:40:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects. Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 02 Oct 2021 16:40:06 +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: patch To: 50967@debbugs.gnu.org Cc: Oleg Pykhalov Received: via spool by 50967-submit@debbugs.gnu.org id=B50967.163319275031878 (code B ref 50967); Sat, 02 Oct 2021 16:40:06 +0000 Received: (at 50967) by debbugs.gnu.org; 2 Oct 2021 16:39:10 +0000 Received: from localhost ([127.0.0.1]:60440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWi2Y-0008I0-G7 for submit@debbugs.gnu.org; Sat, 02 Oct 2021 12:39:10 -0400 Received: from mail-lf1-f48.google.com ([209.85.167.48]:37532) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWi2R-0008FH-1E for 50967@debbugs.gnu.org; Sat, 02 Oct 2021 12:39:03 -0400 Received: by mail-lf1-f48.google.com with SMTP id i4so52189000lfv.4 for <50967@debbugs.gnu.org>; Sat, 02 Oct 2021 09:39:02 -0700 (PDT) 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=AnPHvujA+CU3zczqc4/vpWQDKqC0E7gokczqbnKqoQM=; b=H4QWIb3IQ6l4LbRcU7qGew4kJ4/zZyMUHqtcr2yWDSaajxJLsS94jyrNpCwwgbwPWg IJos8GWHd08gbFMY5pcGF/Jqt59Nj8Mvr23CyRj5m/vgBhv3wYx48GU4+C9je30YE8cJ euplBKiqYr92101ee+v5YXB3lYyrjRLtgVcweQxcyL8k1IbmYIwKca35r0Gp6YHw/AfF TZt7gftw5IpC1icbWqel+t2eFkQ/gYeL4iQQCijPEgVlRl3MV7dU5Z0Om08u0w5u4b/0 93spf5YhuvJ0VOaRUT4jDGGItWf8Wr3kd5IBMIl07FnvlaEYuMPOKL8RDTX5ATigkmnn wvMQ== 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=AnPHvujA+CU3zczqc4/vpWQDKqC0E7gokczqbnKqoQM=; b=K4W9chBmYayRX93gv6kHT17t5PVRp2ewtwoj0qo0kqelEOaMkXtTs5LCQmhNrLF3u+ LQLJ06YpUpQeQ0wrb6wifpUUOSFj9XoNKaSpVwdLhlhr5mFm1gVBVp8XWm8y2VjdSt3C 2JKpyZY/u5iONV8C2/VxxbrjEbxDvcOUvxZ41NF1e9BAk4n0VZ/EOHvXuykGI9DiG+qo m5mo1FSTVorazbZTQIf6SEXkc9ZMyuSDt7CZ85MB18I6YsVnCOu8pV9cYHLvzmYLwamx 1c4LYGpibCRbXnqSpA8MAdVlD8uqJHsD9D6E4cpp8SB79tO6GCaQSK3uss/e62n37d2O 8bSg== X-Gm-Message-State: AOAM532cx9ifDSrkotA5b0RI8LTn1/nXtnondEZEFn4WFagRvtwF1veE EN3UmRfTCPRvtEU/pivbXdC3hVbR8NU= X-Google-Smtp-Source: ABdhPJyaVlGsX/pdgjL5IOYM9ooblGl67lZFtnkDFUBBW0bRogReym5uyAvCrhDE3QjV554dQSoHEg== X-Received: by 2002:a05:651c:988:: with SMTP id b8mr4440535ljq.187.1633192737027; Sat, 02 Oct 2021 09:38:57 -0700 (PDT) Received: from localhost.localdomain ([88.201.161.72]) by smtp.gmail.com with ESMTPSA id h11sm1081487lfc.297.2021.10.02.09.38.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 09:38:56 -0700 (PDT) From: Oleg Pykhalov Date: Sat, 2 Oct 2021 19:38:33 +0300 Message-Id: <20211002163834.29583-13-go.wigust@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211002163834.29583-1-go.wigust@gmail.com> References: <20211002163834.29583-1-go.wigust@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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1633194513; 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=AnPHvujA+CU3zczqc4/vpWQDKqC0E7gokczqbnKqoQM=; b=oygtLzSeo+I0eJkqp9re3qYdqlrCHivNvnRZrdm76GdyAGSceiH0IqIhdel3VYCFfEifvb 1SjFlKycOH3PIH6Q5ZnbKCMx/J3wMJvbPxrQRDo93BsMYl8JRih2kYnsPL4NT+MTQlALtj T+eu+QUH6BO0IGzrTex8JU+cMevIgMf5XEC2GMMYp63XjYodSPX0gkIzWrGC4EDvSzE7CW QUslkhCktX4lGc7ovayoPZzTk3NQ0rUSBuLj6i2tdF7EDZMncbeItwxdI8XmvbgcBPR4HI dav6nNUSckCaccQjGyG8xZcx2U3TvgCIZ+nDydSdQd3kyMUwlF+/KtXETykx4w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633194513; a=rsa-sha256; cv=none; b=DDgd7DZITIpcZIbka+qxEtTlRJ/YEb/Yz3Busdx6Xmlvpnbuz65oNftXHnWjmIoRC77ItI G2F8DEzWJ471Zd4nTsprv+aNOC1tmonHHdquwJ+vtyAiEKFhPLCeN3ojMUIHyoXuDEl1/Y ebWJI1MRGjOjp+ZboEpffd6rC2cvKYhR8Tb3UzLVjn9sPGTQeoB8pRVPWaF0+5+g4tuHsO TF544e8iphU4Dgq31CFawad/1GQq3nNpM5W9/CVw4owdbQBrPAyhj69bj5dnYWS6LSQi2e 8+kdsZvom5ORLJ1FSGS9nMsYfM4BpFYI/SrdeKBakZD//kxbji7dGfi6Vld7CA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=H4QWIb3I; 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: 2.29 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=H4QWIb3I; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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: 805E13350E X-Spam-Score: 2.29 X-Migadu-Scanner: scn1.migadu.com X-TUID: NhAf+iHaFb1G * gnu/home/services/configuration.scm (interpose): Include content of files. (string-or-gexp?): Rename to 'file-or-string-or-gexp?' and check for file-like object. (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/configuration.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 GRAMMAR 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 them." (define alist? list?) -(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) "") (define (text-config? config) - (and (list? config) (every string-or-gexp? config))) + (and (list? config) (every file-or-string-or-gexp? config))) (define (serialize-text-config field-name val) #~(string-append #$@(interpose val "\n" 'suffix))) 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)))) '())))))) -- 2.33.0