From patchwork Sat Oct 30 10:42:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 34153 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 6BF0C27BBE3; Sat, 30 Oct 2021 11:43:22 +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 97B0027BBE1 for ; Sat, 30 Oct 2021 11:43:21 +0100 (BST) Received: from localhost ([::1]:51992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mglpY-0001IO-Mj for patchwork@mira.cbaines.net; Sat, 30 Oct 2021 06:43:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mglpG-0000tz-Mu for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45184) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mglpG-0001sD-Dt 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-0002bB-C8 for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH v3 1/8] guix home: import: Make the user to specify a destination directory. 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.16355905649905 (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]:56716 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mglox-0002Zg-JY 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]:59260 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mglon-0002YY-Qh for 50873@debbugs.gnu.org; Sat, 30 Oct 2021 06:42:34 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1635590548; bh=DbXLvNf2Gp330sdB/TY7J5Tet0J5OWXLZky0C2PXlt4=; h=From:To:Subject:In-Reply-To:References:Date; b=MHeTSnstulwiep8iR6oNwalnmuX6GB3hO25hA1allKP4+ckH8yMTIJ1jTFvDB1elC CSTGtbFh0tfSBPm4V7Zz37pgxaF4nz739Nedp/6hS7bxz6+3Lh6wtEy9WjPBHhm39E Hn5twp5DmgqrWttoDNVJh7pKeXhoLkYI++AUYlxs= In-Reply-To: References: Message-Id: <4b3eb05f3fb1bfbd3e7f16c3ba5862a603372df0.1635590221.git.public@yoctocell.xyz> Date: Sat, 30 Oct 2021 12:42:27 +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 Copy the appropriate the relevant configuration files to the destination directory, and call ‘local-file’ on them. Without this, ‘guix home import’ will generate a service declaration like this (service home-bash-service-type (home-bash-configuration (bashrc (list (slurp-file-gexp (local-file "/home/yoctocell/.bashrc")))))) but when running ‘guix home reconfigure’, the ~/.bashrc file would be moved, so when running ‘guix home reconfigure’ for the second time, it would read the ~/.bashrc which is itself a symlink to a file the store. * guix/scripts/home/import.scm (generate-bash-module+configuration): Take ‘destination-directory’ parameter (modules+configurations): Copy the user’s configuration file to ‘%destination-directory’. * guix/scripts/home.scm (process-command): Adjust accordingly; create ‘destination’ if it doesn’t exist. --- guix/scripts/home.scm | 24 ++++++---- guix/scripts/home/import.scm | 86 +++++++++++++++++++++--------------- 2 files changed, 65 insertions(+), 45 deletions(-) diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index 55e7b436c1..3f48b98ed4 100644 --- a/guix/scripts/home.scm +++ b/guix/scripts/home.scm @@ -40,6 +40,7 @@ (define-module (guix scripts home) #:autoload (guix scripts pull) (channel-commit-hyperlink) #:use-module (guix scripts home import) #:use-module ((guix status) #:select (with-status-verbosity)) + #:use-module ((guix build utils) #:select (mkdir-p)) #:use-module (guix gexp) #:use-module (guix monads) #:use-module (srfi srfi-1) @@ -260,15 +261,20 @@ (define-syntax-rule (with-store* store exp ...) (apply search args)) ((import) (let* ((profiles (delete-duplicates - (match (filter-map (match-lambda - (('profile . p) p) - (_ #f)) - opts) - (() (list %current-profile)) - (lst (reverse lst))))) - (manifest (concatenate-manifests - (map profile-manifest profiles)))) - (import-manifest manifest (current-output-port)))) + (match (filter-map (match-lambda + (('profile . p) p) + (_ #f)) + opts) + (() (list %current-profile)) + (lst (reverse lst))))) + (manifest (concatenate-manifests + (map profile-manifest profiles))) + (destination (match args + ((destination) destination) + (_ (leave (G_ "wrong number of arguments~%")))))) + (unless (file-exists? destination) + (mkdir-p destination)) + (import-manifest manifest destination (current-output-port)))) ((describe) (match (generation-number %guix-home) (0 diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index 611f580e85..c7c60e95e8 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -36,49 +36,61 @@ (define-module (guix scripts home import) ;;; ;;; Code: +(define (generate-bash-configuration+modules destination-directory) + (define (destination-append path) + (string-append destination-directory "/" path)) -(define (generate-bash-module+configuration) - (let ((rc (string-append (getenv "HOME") "/.bashrc")) - (profile (string-append (getenv "HOME") "/.bash_profile")) - (logout (string-append (getenv "HOME") "/.bash_logout"))) - `((gnu home services bash) + (let ((rc (destination-append ".bashrc")) + (profile (destination-append ".bash_profile")) + (logout (destination-append ".bash_logout"))) + `((gnu home-services bash) (service home-bash-service-type - (home-bash-configuration - ,@(if (file-exists? rc) - `((bashrc - (list (local-file ,rc)))) - '()) - ,@(if (file-exists? profile) - `((bash-profile - (list (local-file ,profile)))) - '()) - ,@(if (file-exists? logout) - `((bash-logout - (list (local-file ,logout)))) - '())))))) - + (home-bash-configuration + ,@(if (file-exists? rc) + `((bashrc + (list (slurp-file-gexp + (local-file ,rc))))) + '()) + ,@(if (file-exists? profile) + `((bash-profile + (list (slurp-file-gexp + (local-file ,profile))))) + '()) + ,@(if (file-exists? logout) + `((bash-logout + (list (slurp-file-gexp + (local-file ,logout))))) + '())))))) (define %files-configurations-alist `((".bashrc" . ,generate-bash-module+configuration) (".bash_profile" . ,generate-bash-module+configuration) (".bash_logout" . ,generate-bash-module+configuration))) -(define (modules+configurations) - (let ((configurations (delete-duplicates - (filter-map (match-lambda - ((file . proc) - (if (file-exists? - (string-append (getenv "HOME") "/" file)) - proc - #f))) - %files-configurations-alist) - (lambda (x y) - (equal? (procedure-name x) (procedure-name y)))))) - (map (lambda (proc) (proc)) configurations))) +(define (configurations+modules destination-directory) + "Return a list of procedures which when called, generate code for a home +service declaration." + (define configurations + (delete-duplicates + (filter-map (match-lambda + ((file . proc) + (let ((absolute-path (string-append (getenv "HOME") + "/" file))) + (and (file-exists? absolute-path) + (begin + (copy-file absolute-path + (string-append + destination-directory "/" file)) + proc))))) + %files+configurations-alist) + (lambda (x y) + (equal? (procedure-name x) (procedure-name y))))) + + (map (lambda (proc) (proc destination-directory)) configurations)) ;; Based on `manifest->code' from (guix profiles) ;; MAYBE: Upstream it? -(define* (manifest->code manifest +(define* (manifest->code manifest destination-directory #:key (entry-package-version (const "")) (home-environment? #f)) @@ -129,7 +141,8 @@ (define (qualified-name entry) ":" output)))) (manifest-entries manifest)))) (if home-environment? - (let ((modules+configurations (modules+configurations))) + (let ((configurations+modules + (configurations+modules destination-directory))) `(begin (use-modules (gnu home) (gnu packages) @@ -171,7 +184,8 @@ (define name (options->transformation ',options)))) transformation-procedures))) (if home-environment? - (let ((modules+configurations (modules+configurations))) + (let ((configurations+modules + (configurations+modules destination-directory))) `(begin (use-modules (guix transformations) (gnu home) @@ -204,7 +218,7 @@ (define* (home-environment-template #:key (packages #f) (specs #f) services) (services (list ,@services)))) (define* (import-manifest - manifest + manifest destination-directory #:optional (port (current-output-port))) "Write to PORT a corresponding to MANIFEST." (define (version-spec entry) @@ -227,7 +241,7 @@ (define (version-spec entry) (version-unique-prefix (manifest-entry-version entry) versions))))))) - (match (manifest->code manifest + (match (manifest->code manifest destination-directory #:entry-package-version version-spec #:home-environment? #t) (('begin exp ...) 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)) From patchwork Sat Oct 30 10:42:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 34155 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 CEF4827BBE3; Sat, 30 Oct 2021 11:43:23 +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 A70EE27BBE1 for ; Sat, 30 Oct 2021 11:43:23 +0100 (BST) Received: from localhost ([::1]:52176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mglpa-0001Q1-Ns for patchwork@mira.cbaines.net; Sat, 30 Oct 2021 06:43:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mglpH-0000uL-U0 for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45187) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mglpH-0001sX-LT for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mglpH-0002bX-IG for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH v3 3/8] guix home: import: Fix module name for Bash service. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 30 Oct 2021 10:43:03 +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.16355905659928 (code B ref 50873); Sat, 30 Oct 2021 10:43:03 +0000 Received: (at 50873) by debbugs.gnu.org; 30 Oct 2021 10:42:45 +0000 Received: from localhost ([127.0.0.1]:56722 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgloy-0002Zx-MR 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]:59298 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mglou-0002Z0-91 for 50873@debbugs.gnu.org; Sat, 30 Oct 2021 06:42:40 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1635590554; bh=adDv+Gm68BKmwCHYqORofe/Nt4AMSQofFsDh/mG139c=; h=From:To:Subject:In-Reply-To:References:Date; b=Dx72gKukqOTjgLo6xdSDLLlrTE1pC0Z3Y33pFqkCX2oXHsanxXLW2rEm+SdK07n1s mdHDK7kEZfozKnit+pv0hzi0WjyeyrTrFLc+MmDiRsWfJvXAhCr210VpZwJg71YV3U axULBiOBQyjz5wJXN9vWXiO6pgyNxh6ZGtdp6Gpg= In-Reply-To: References: Message-Id: Date: Sat, 30 Oct 2021 12:42:34 +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 * guix/scripts/home/import.scm (generate-bash-configuration+modules): Change (gnu home-services bash) to (gnu home-services shells); add (guix gexp). --- guix/scripts/home/import.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index 533abdbb8d..f20088aa88 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -60,7 +60,8 @@ (define (destination-append path) (list (slurp-file-gexp (local-file ,logout))))) '()))) - (gnu home-services bash)))) + (guix gexp) + (gnu home services shells)))) From patchwork Sat Oct 30 10:42:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 34156 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 8483327BBE3; Sat, 30 Oct 2021 11:43:29 +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 49C0A27BBE1 for ; Sat, 30 Oct 2021 11:43:29 +0100 (BST) Received: from localhost ([::1]:52612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mglpg-0001i9-Aa for patchwork@mira.cbaines.net; Sat, 30 Oct 2021 06:43:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mglpI-0000uM-B8 for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45188) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mglpI-0001sd-2f for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mglpI-0002be-0r for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH v3 4/8] guix home: import: =?utf-8?b?RG9u4oCZ?= =?utf-8?b?dA==?= use 'slurp-file-gexp'. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 30 Oct 2021 10:43:03 +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.16355905659936 (code B ref 50873); Sat, 30 Oct 2021 10:43:03 +0000 Received: (at 50873) by debbugs.gnu.org; 30 Oct 2021 10:42:45 +0000 Received: from localhost ([127.0.0.1]:56724 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgloy-0002a5-V5 for submit@debbugs.gnu.org; Sat, 30 Oct 2021 06:42:45 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:59316 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mglov-0002Z4-Li for 50873@debbugs.gnu.org; Sat, 30 Oct 2021 06:42:41 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1635590556; bh=tuaDtfAB9naSyhgcuSqdF0v9pM8cfJbY+1323HVgeoc=; h=From:To:Subject:In-Reply-To:References:Date; b=fHR4m6ZKCgaRmqwag5kt1PWc7IcDeyG06BFtmMAWLRjHMLqkevupbGd8QT4CzGUEN lpq1JXvC9+VJr5/TZNxrGRHy2XFA2nGpBR3uyRAaobBm19gAm3bWQXc6yWFX3vseJs RO3q9qwUOT/bG7YCq5ISxH/7V3qlGXtqoN4HOS94= In-Reply-To: References: Message-Id: Date: Sat, 30 Oct 2021 12:42:35 +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 ‘slurp-file-gexp’ is not a bound procedure. * guix/scripts/home/import.scm (generate-bash-configuration+modules): Don’t use ‘slurp-file-gexp’. --- guix/scripts/home/import.scm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index f20088aa88..0e7c454f45 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -47,24 +47,19 @@ (define (destination-append path) (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)))) '()))) (guix gexp) (gnu home services shells)))) - - (define %files+configurations-alist `((".bashrc" . ,generate-bash-configuration+modules) (".bash_profile" . ,generate-bash-configuration+modules) From patchwork Sat Oct 30 10:42:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 34154 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 70DD227BBE3; Sat, 30 Oct 2021 11:43:23 +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 4046427BBE1 for ; Sat, 30 Oct 2021 11:43:23 +0100 (BST) Received: from localhost ([::1]:52132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mglpa-0001OE-9Q for patchwork@mira.cbaines.net; Sat, 30 Oct 2021 06:43:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mglpJ-0000vu-6W for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45190) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mglpI-0001sp-UY for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mglpI-0002bt-Sc for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH v3 5/8] guix home: import: Delete duplicate modules when importing. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 30 Oct 2021 10:43:04 +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.16355905669950 (code B ref 50873); Sat, 30 Oct 2021 10:43:04 +0000 Received: (at 50873) by debbugs.gnu.org; 30 Oct 2021 10:42:46 +0000 Received: from localhost ([127.0.0.1]:56728 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgloz-0002aL-Pa for submit@debbugs.gnu.org; Sat, 30 Oct 2021 06:42:46 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:59332 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mglow-0002Z6-SY for 50873@debbugs.gnu.org; Sat, 30 Oct 2021 06:42:43 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1635590557; bh=Hd1VakLjtxnp6jV7Q0I9BKs8lo/pxC+h662NKXyuRvs=; h=From:To:Subject:In-Reply-To:References:Date; b=lB4qnlY62dSgSMO87xm7ZwTFDkyuiCZZBFoLQA8UV0Kqs41WmGt9dQfVXGPv+AqCb 5OB0pODejG0IK6RYpDcfGSlGJ6aOPESfR/Gpa0LPjdSpZVfgyUtRAttn+5V66bM3Z6 OzlCpTp2y3j3xNoUKePM83Ax9Tklz15aD5QCFA24= In-Reply-To: References: Message-Id: <40ca56d2d949f7a56bce56d1221396fb85e57a4d.1635590221.git.public@yoctocell.xyz> Date: Sat, 30 Oct 2021 12:42:37 +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 Two different services might require the same module(s), so delete duplicates when generating the ‘use-modules’ form. * import.scm (manifest->code): Delete duplicate modules. --- guix/scripts/home/import.scm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index 0e7c454f45..f0ae233b75 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -145,7 +145,8 @@ (define (qualified-name entry) (use-modules (gnu home) (gnu packages) (gnu services) - ,@(concatenate (map cdr configurations+modules))) + ,@((compose delete-duplicates concatenate) + (map cdr configurations+modules))) ,(home-environment-template #:specs specs #:services (map first configurations+modules)))) @@ -190,7 +191,8 @@ (define name (gnu home) (gnu packages) (gnu services) - ,@(concatenate (map cdr configurations+modules))) + ,@((compose delete-duplicates concatenate) + (map cdr configurations+modules))) ,@transformations From patchwork Sat Oct 30 10:42:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 34151 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 3563327BBE4; 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 D9B1727BBE1 for ; Sat, 30 Oct 2021 11:43:15 +0100 (BST) Received: from localhost ([::1]:51526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mglpS-0000z1-Vn for patchwork@mira.cbaines.net; Sat, 30 Oct 2021 06:43:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mglpH-0000u8-Eu for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45186) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mglpH-0001sP-6j for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mglpH-0002bQ-5Z for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH v3 6/8] doc: Document the =?utf-8?b?4oCYZ3VpeA==?= home =?utf-8?b?aW1wb3J04oCZ?= subcommand. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 30 Oct 2021 10:43:03 +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.16355905649920 (code B ref 50873); Sat, 30 Oct 2021 10:43:03 +0000 Received: (at 50873) by debbugs.gnu.org; 30 Oct 2021 10:42:44 +0000 Received: from localhost ([127.0.0.1]:56720 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgloy-0002Zq-Cp 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 1mglot-0002Ym-To for 50873@debbugs.gnu.org; Sat, 30 Oct 2021 06:42:40 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1635590559; bh=b2I1puvfEgZK0r8OCRM0fx0ZujqguLZnSkyEHQd8OLY=; h=From:To:Subject:In-Reply-To:References:Date; b=K/LJIPvs3KtwMnODfjucPhc4qOSfyTmQp2Ii4y2ySIRRSWR725q3/xNNnJwR5FnZF d/1IdWwwGxMa+XTCW/1+49ZtzFeE8qHGfY/vUN5dsFxDeFavXcwQZU5ni1tZnai69u A0lMVzciu0q5HxaqQuo0scwLKVzqpxav+/+C2wbs= In-Reply-To: References: Message-Id: Date: Sat, 30 Oct 2021 12:42:39 +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 * doc/guix.texi (Invoking guix home): Document ‘guix home import’. --- doc/guix.texi | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 22215214e0..3c069912cb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -36509,6 +36509,38 @@ $ guix home list-generations 10d @end example +@item import +Generate a @dfn{home environment} from the packages in the default +profile and configuration files found in the user's home directory. The +configuration files will be copied to the specified directory. Note +that not every home service that exists is supported (@pxref{Home +Services}). + +@example +$ guix home import ~/guix-config +;; This "home-environment" file can be passed to 'guix home reconfigure' +;; to reproduce the content of your profile. This is "symbolic": it only +;; specifies package names. To reproduce the exact same profile, you also +;; need to capture the channels being used, as returned by "guix describe". +;; See the "Replicating Guix" section in the manual. + +(use-modules + (gnu home) + (gnu packages) + (gnu home services shells)) + +(home-environment + (packages + (map specification->package + (list "glibc-locales" "nss-certs" "nss"))) + (services + (list (service + home-bash-service-type + (home-bash-configuration + (bashrc + (list (local-file "/tmp/guix-config/.bashrc")))))))) +@end example + @end table @var{options} can contain any of the common build options (@pxref{Common From patchwork Sat Oct 30 10:42:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 34157 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 4534527BBE3; Sat, 30 Oct 2021 11:43:31 +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 A099327BBE1 for ; Sat, 30 Oct 2021 11:43:30 +0100 (BST) Received: from localhost ([::1]:52770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mglph-0001or-On for patchwork@mira.cbaines.net; Sat, 30 Oct 2021 06:43:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mglpI-0000vW-Ou for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45189) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mglpI-0001si-GS for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mglpI-0002bm-EV for guix-patches@gnu.org; Sat, 30 Oct 2021 06:43:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH v3 7/8] Add tests for =?utf-8?b?4oCYZ3VpeA==?= home =?utf-8?b?aW1wb3J04oCZLg==?= Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 30 Oct 2021 10:43:04 +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.16355905659944 (code B ref 50873); Sat, 30 Oct 2021 10:43:04 +0000 Received: (at 50873) by debbugs.gnu.org; 30 Oct 2021 10:42:45 +0000 Received: from localhost ([127.0.0.1]:56726 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgloz-0002aC-7t for submit@debbugs.gnu.org; Sat, 30 Oct 2021 06:42:45 -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 1mglow-0002Ym-2u for 50873@debbugs.gnu.org; Sat, 30 Oct 2021 06:42:43 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1635590561; bh=znJE00iO9gzUCIF4qyxUh7oFJv91ZF0FUK+bRp9Ha+g=; h=From:To:Subject:In-Reply-To:References:Date; b=Mm3OkShhUNuj1POfqFUIJQ6TTyMk3xyjg4YdIRv/8qNChI1QtRKzzhXD566DCQaCP TB7TrwuOwfoei01FBs8YKFzJakkm6dQVPsu2xzjKlb67g1t0Ag9bMhAjDrMtGavivW LXxyvFBJsZG85RwZ8Ad45OiJ/uaEEi4kI3i/hOxE= In-Reply-To: References: Message-Id: <92b43fa1b99c1f3c65d3985fa99579fb82b43ca8.1635590221.git.public@yoctocell.xyz> Date: Sat, 30 Oct 2021 12:42:41 +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 * tests/home-import.scm: New file. * Makefile.am (SCM_TESTS): Add it. --- Makefile.am | 1 + guix/scripts/home/import.scm | 7 +- tests/home-import.scm | 179 +++++++++++++++++++++++++++++++++++ 3 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 tests/home-import.scm diff --git a/Makefile.am b/Makefile.am index 239387c2f4..d608b08899 100644 --- a/Makefile.am +++ b/Makefile.am @@ -475,6 +475,7 @@ SCM_TESTS = \ tests/graph.scm \ tests/gremlin.scm \ tests/hackage.scm \ + tests/home-import.scm \ tests/import-git.scm \ tests/import-utils.scm \ tests/inferior.scm \ diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index f0ae233b75..6e3ed065d5 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -27,7 +27,10 @@ (define-module (guix scripts home import) #:use-module (ice-9 pretty-print) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) - #:export (import-manifest)) + #:export (import-manifest + + ;; For tests. + manifest->code)) ;;; Commentary: ;;; @@ -36,6 +39,8 @@ (define-module (guix scripts home import) ;;; ;;; Code: + + (define (generate-bash-configuration+modules destination-directory) (define (destination-append path) (string-append destination-directory "/" path)) diff --git a/tests/home-import.scm b/tests/home-import.scm new file mode 100644 index 0000000000..a4e71fa698 --- /dev/null +++ b/tests/home-import.scm @@ -0,0 +1,179 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Xinglu Chen . + +(define-module (test-home-import) + #:use-module (guix scripts home import) + #:use-module (guix utils) + #:use-module (guix build utils) + #:use-module (guix packages) + #:use-module (ice-9 match) + #:use-module ((guix profiles) #:hide (manifest->code)) + #:use-module ((guix build syscalls) #:select (mkdtemp!)) + #:use-module (gnu packages) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (srfi srfi-64)) + +;; Test the (guix scripts home import) tools. + +(test-begin "home-import") + +;; Example manifest entries. + +(define guile-2.0.9 + (manifest-entry + (name "guile") + (version "2.0.9") + (item "/gnu/store/..."))) + +(define glibc + (manifest-entry + (name "glibc") + (version "2.19") + (item "/gnu/store/..."))) + +(define gcc + (manifest-entry + (name "gcc") + (version "10.3.0") + (item "/gnu/store/..."))) + +;; Helpers for checking and generating home environments. + +(define %destination-directory "/tmp/guix-config") +(mkdir-p %destination-directory) + +(define %temporary-home-directory (mkdtemp! "/tmp/guix-home-import.XXXXXX")) + +(define-syntax-rule (define-home-environment-matcher name pattern) + (define (name obj) + (match obj + (pattern #t) + (x (pk 'fail x #f))))) + +(define (create-temporary-home files-alist) + "Create a temporary home directory in '%temporary-home-directory'. +FILES-ALIST is an association list of files and the content of the +corresponding file." + (define (create-file file content) + (let ((absolute-path (string-append %temporary-home-directory "/" file))) + (unless (file-exists? absolute-path) + (mkdir-p (dirname absolute-path))) + (call-with-output-file absolute-path + (cut display content <>)))) + + (for-each (match-lambda + ((file . content) (create-file file content))) + files-alist)) + +;; Copied from (guix profiles) +(define (version-spec entry) + (let ((name (manifest-entry-name entry))) + (match (map package-version (find-packages-by-name name)) + ((_) + ;; A single version of NAME is available, so do not specify the + ;; version number, even if the available version doesn't match ENTRY. + "") + (versions + ;; If ENTRY uses the latest version, don't specify any version. + ;; Otherwise return the shortest unique version prefix. Note that + ;; this is based on the currently available packages, which could + ;; differ from the packages available in the revision that was used + ;; to build MANIFEST. + (let ((current (manifest-entry-version entry))) + (if (every (cut version>? current <>) + (delete current versions)) + "" + (version-unique-prefix (manifest-entry-version entry) + versions))))))) + +(define (eval-test-with-home-environment files-alist manifest matcher) + (create-temporary-home files-alist) + (setenv "HOME" %temporary-home-directory) + (mkdir-p %temporary-home-directory) + (let* ((home-environment (manifest->code manifest %destination-directory + #:entry-package-version version-spec + #:home-environment? #t)) + (result (matcher home-environment))) + (delete-file-recursively %temporary-home-directory) + result)) + +(define-home-environment-matcher match-home-environment-no-services + ('begin + ('use-modules + ('gnu 'home) + ('gnu 'packages) + ('gnu 'services)) + ('home-environment + ('packages + ('map 'specification->package + ('list "guile@2.0.9" "gcc" "glibc@2.19"))) + ('services + ('list))))) + +(define-home-environment-matcher match-home-environment-no-services-nor-packages + ('begin + ('use-modules + ('gnu 'home) + ('gnu 'packages) + ('gnu 'services)) + ('home-environment + ('packages + ('map 'specification->package + ('list))) + ('services + ('list))))) + +(define-home-environment-matcher match-home-environment-bash-service + ('begin + ('use-modules + ('gnu 'home) + ('gnu 'packages) + ('gnu 'services) + ('guix 'gexp) + ('gnu 'home 'services 'shells)) + ('home-environment + ('packages + ('map 'specification->package + ('list))) + ('services + ('list ('service + 'home-bash-service-type + ('home-bash-configuration + ('bashrc + ('list ('local-file "/tmp/guix-config/.bashrc")))))))))) + +(test-assert "manifest->code: No services" + (eval-test-with-home-environment + '() + (make-manifest (list guile-2.0.9 gcc glibc)) + match-home-environment-no-services)) + +(test-assert "manifest->code: No packages nor services" + (eval-test-with-home-environment + '() + (make-manifest '()) + match-home-environment-no-services-nor-packages)) + +(test-assert "manifest->code: Bash service" + (eval-test-with-home-environment + '((".bashrc" . "echo 'hello guix'")) + (make-manifest '()) + match-home-environment-bash-service)) + +(test-end "home-import") From patchwork Sat Oct 30 10:42:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 34158 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 EFBC927BBE3; Sat, 30 Oct 2021 11:44:08 +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 BDAA427BBE1 for ; Sat, 30 Oct 2021 11:44:08 +0100 (BST) Received: from localhost ([::1]:53144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mglqJ-00025c-Ua for patchwork@mira.cbaines.net; Sat, 30 Oct 2021 06:44:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mglqE-00025U-JH for guix-patches@gnu.org; Sat, 30 Oct 2021 06:44:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45193) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mglqE-00023Q-Ay for guix-patches@gnu.org; Sat, 30 Oct 2021 06:44:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mglqE-0002dd-9E for guix-patches@gnu.org; Sat, 30 Oct 2021 06:44:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH v3 8/8] guix home: import: Call =?utf-8?b?4oCY?= =?utf-8?b?bG9jYWwtZmlsZeKAmQ==?= with =?utf-8?b?4oCYbmFtZeKAmQ==?= Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 30 Oct 2021 10:44: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.163559061210088 (code B ref 50873); Sat, 30 Oct 2021 10:44:02 +0000 Received: (at 50873) by debbugs.gnu.org; 30 Oct 2021 10:43:32 +0000 Received: from localhost ([127.0.0.1]:56739 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mglpk-0002ce-4d for submit@debbugs.gnu.org; Sat, 30 Oct 2021 06:43:32 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:59378 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mglp4-0002a4-4g for 50873@debbugs.gnu.org; Sat, 30 Oct 2021 06:42:50 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1635590564; bh=UfY9+sc2B8doB9Z7PPiKrSE05DUz+hLQryKoFe2kmWc=; h=From:To:Subject:In-Reply-To:References:Date; b=lipI8QytGuzGQ5MvkifBXAi9tSO6TbR2UQETHykOfPV9AZoKCxBCgfdfoRgA42r7Y 6Pado9K6ZvIrc8fCf16na9btlmm/7KX5ABXviJpcbPf+t+rpqCOl3vXkrUluQh6pr/ RV09E/LYxN1qxGswFvvja0hv3ulR5naVVVxrWj60= In-Reply-To: References: Message-Id: <19dd061d4f7a3aab24ecb660df01e3c6613d4ae7.1635590221.git.public@yoctocell.xyz> Date: Sat, 30 Oct 2021 12:42:44 +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 Set the name of the file to just the basename of the file passed to ‘local-file’. * guix/scripts/home/import.scm (basename+remove-dots): New procedure. (generate-bash-configuration+modules): Use it. * tests/home-import.scm (match-home-environment-bash-service): Adjust accordingly. --- guix/scripts/home/import.scm | 20 ++++++++++++++++---- tests/home-import.scm | 3 ++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index 6e3ed065d5..a0022458f6 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -39,7 +39,16 @@ (define-module (guix scripts home import) ;;; ;;; Code: - +(define (basename+remove-dots file-name) + "Remove the dot from the dotfile FILE-NAME; replace the other dots in +FILE-NAME with \"-\", and return the basename of it." + (string-map (match-lambda + (#\. #\-) + (c c)) + (let ((base (basename file-name))) + (if (string-prefix? "." base) + (string-drop base 1) + base)))) (define (generate-bash-configuration+modules destination-directory) (define (destination-append path) @@ -52,15 +61,18 @@ (define (destination-append path) (home-bash-configuration ,@(if (file-exists? rc) `((bashrc - (list (local-file ,rc)))) + (list (local-file ,rc + ,(basename+remove-dots rc))))) '()) ,@(if (file-exists? profile) `((bash-profile - (list (local-file ,profile)))) + (list (local-file ,profile + ,(basename+remove-dots profile))))) '()) ,@(if (file-exists? logout) `((bash-logout - (list (local-file ,logout)))) + (list (local-file ,logout + ,(basename+remove-dots logout))))) '()))) (guix gexp) (gnu home services shells)))) diff --git a/tests/home-import.scm b/tests/home-import.scm index a4e71fa698..d2f5728e3c 100644 --- a/tests/home-import.scm +++ b/tests/home-import.scm @@ -156,7 +156,8 @@ (define-home-environment-matcher match-home-environment-bash-service 'home-bash-service-type ('home-bash-configuration ('bashrc - ('list ('local-file "/tmp/guix-config/.bashrc")))))))))) + ('list ('local-file "/tmp/guix-config/.bashrc" + "bashrc")))))))))) (test-assert "manifest->code: No services" (eval-test-with-home-environment