From patchwork Sat Oct 2 16:38:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Pykhalov X-Patchwork-Id: 33578 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id CE50927BBE3; Sat, 2 Oct 2021 17:41:13 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6C2E827BBE1 for ; Sat, 2 Oct 2021 17:41:13 +0100 (BST) Received: from localhost ([::1]:47962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWi4W-0003Og-Ht for patchwork@mira.cbaines.net; Sat, 02 Oct 2021 12:41:12 -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 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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)))) '()))))))