From patchwork Sat Oct 30 10:42:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 34152 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 9E3BC27BBE1; Sat, 30 Oct 2021 11:43:16 +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_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED 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 205FB27BBE3 for ; Sat, 30 Oct 2021 11:43:16 +0100 (BST) Received: from localhost ([::1]:51514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mglpT-0000yQ-1q for patchwork@mira.cbaines.net; Sat, 30 Oct 2021 06:43:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mglpH-0000u0-3b for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45185) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mglpG-0001sJ-Rf for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mglpG-0002bI-P7 for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH v3 2/8] guix home: import: Allow multiple modules to be imported for each service. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 30 Oct 2021 10:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50873 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50873@debbugs.gnu.org, Oleg Pykhalov , Andrew Tropin , Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 50873-submit@debbugs.gnu.org id=B50873.16355905649913 (code B ref 50873); Sat, 30 Oct 2021 10:43:02 +0000 Received: (at 50873) by debbugs.gnu.org; 30 Oct 2021 10:42:44 +0000 Received: from localhost ([127.0.0.1]:56718 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgloy-0002Zi-1X for submit@debbugs.gnu.org; Sat, 30 Oct 2021 06:42:44 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:59288 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mglos-0002Ym-Ib for 50873@debbugs.gnu.org; Sat, 30 Oct 2021 06:42:39 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1635590553; bh=bAoSPT5UtBV5uzz4Gu8EWor07tyBeFgdVq/fKmyuhq0=; h=From:To:Subject:In-Reply-To:References:Date; b=pSKso8JClsqDDd5bJeiRBQ01rfwwvmMSwHTsSlzH3xPl/JcXDuWAzSu0c6geWEWFG YaVS+VUwAt8hYfRV8BG2Eo5XROe+x7WFTz0tbu8EjxKZofUgNVn7mrTW6ZnQwmkQ1D vCyYPMXnhVoiw7elf/NlKfiZ01BbzaFoHdS83vl8= In-Reply-To: References: Message-Id: <1002d5577006cc804193f34237415c9707942e27.1635590221.git.public@yoctocell.xyz> Date: Sat, 30 Oct 2021 12:42:32 +0200 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 Previously, only one module could be imported for each service, e.g., only (gnu home-services shell) could be imported when generating the Bash service declaration. However, for some services, multiple modules might need to be imported in order for it to work. * guix/scripts/home/import.scm (generate-bash-module+configuration): Rename to ... (generate-bash-configuration+modules): ... this. (%files-configurations-alist): Rename to ... (%files+configurations-alist): ... this. (modules+configurations): Rename to ... (configurations+modules): ... this. (manifest->code): Adjust accordingly. --- guix/scripts/home/import.scm | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index c7c60e95e8..533abdbb8d 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -43,8 +43,7 @@ (define (destination-append path) (let ((rc (destination-append ".bashrc")) (profile (destination-append ".bash_profile")) (logout (destination-append ".bash_logout"))) - `((gnu home-services bash) - (service home-bash-service-type + `((service home-bash-service-type (home-bash-configuration ,@(if (file-exists? rc) `((bashrc @@ -60,12 +59,15 @@ (define (destination-append path) `((bash-logout (list (slurp-file-gexp (local-file ,logout))))) - '())))))) + '()))) + (gnu home-services bash)))) -(define %files-configurations-alist - `((".bashrc" . ,generate-bash-module+configuration) - (".bash_profile" . ,generate-bash-module+configuration) - (".bash_logout" . ,generate-bash-module+configuration))) + + +(define %files+configurations-alist + `((".bashrc" . ,generate-bash-configuration+modules) + (".bash_profile" . ,generate-bash-configuration+modules) + (".bash_logout" . ,generate-bash-configuration+modules))) (define (configurations+modules destination-directory) "Return a list of procedures which when called, generate code for a home @@ -144,12 +146,13 @@ (define (qualified-name entry) (let ((configurations+modules (configurations+modules destination-directory))) `(begin - (use-modules (gnu home) - (gnu packages) - ,@(map first modules+configurations)) - ,(home-environment-template - #:specs specs - #:services (map second modules+configurations)))) + (use-modules (gnu home) + (gnu packages) + (gnu services) + ,@(concatenate (map cdr configurations+modules))) + ,(home-environment-template + #:specs specs + #:services (map first configurations+modules)))) `(begin (use-modules (gnu packages)) @@ -190,13 +193,14 @@ (define name (use-modules (guix transformations) (gnu home) (gnu packages) - ,@(map first modules+configurations)) + (gnu services) + ,@(concatenate (map cdr configurations+modules))) ,@transformations ,(home-environment-template #:packages packages - #:services (map second modules+configurations)))) + #:services (map first configurations+modules)))) `(begin (use-modules (guix transformations) (gnu packages))