From patchwork Sun Oct 10 10:20:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 33728 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 5BC9527BBE4; Sun, 10 Oct 2021 11:21:25 +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 A1DA127BBE3 for ; Sun, 10 Oct 2021 11:21:24 +0100 (BST) Received: from localhost ([::1]:33700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZVxL-0003cS-Kp for patchwork@mira.cbaines.net; Sun, 10 Oct 2021 06:21:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZVx1-0003ai-VE for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42963) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZVx0-00050F-5W for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mZVx0-0003Ov-1Z for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH 1/7] 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: Sun, 10 Oct 2021 10:21:01 +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 Cc: Oleg Pykhalov , Ludovic =?utf-8?q?Court=C3=A8s?= , Andrew Tropin Received: via spool by 50873-submit@debbugs.gnu.org id=B50873.163386121912920 (code B ref 50873); Sun, 10 Oct 2021 10:21:01 +0000 Received: (at 50873) by debbugs.gnu.org; 10 Oct 2021 10:20:19 +0000 Received: from localhost ([127.0.0.1]:54490 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwJ-0003MJ-7R for submit@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:19 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:39716 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwG-0003Lt-Vo for 50873@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:17 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1633861211; bh=GjCDFBVPzoLpomEwylpSfTEdA589GFIwlMJCLptPUyo=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=VgYbwohlQkJZE7h1HrQrGwiOAsFdvYiQq/EcAV9we8BMRNHmS9o5tQVoSZ6ELA5Ds jdM9ZRHTWR7Z8+eaI1BJ2tej3iPnVgZtnKtI9RVkLCdTM7+oSKBCwwiTCdIUKMp5jU znIYvy/GFCqsHf5RJ9CedidWYw9u7sC+oT/RWkys= In-Reply-To: References: Message-Id: <9db0424f9494d3d15e534eb75773ae9bd3f33cb3.1633861021.git.public@yoctocell.xyz> Date: Sun, 10 Oct 2021 12:20:11 +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 (%destination-directory): New parameter. (generate-bash-module+configuration): Adjust accordingly. (modules+configurations): Copy the user’s configuration file to ‘%destination-directory’. * guix/scripts/home.scm (process-command): Adjust accordingly; create ‘%destination-directory’ if it doesn’t exist. --- guix/scripts/home.scm | 25 +++++++----- guix/scripts/home/import.scm | 75 +++++++++++++++++++++--------------- 2 files changed, 61 insertions(+), 39 deletions(-) diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index 55e7b436c1..520360e14a 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,21 @@ (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)) + (parameterize ((%destination-directory destination)) + (import-manifest manifest (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..a6ab68a32c 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -27,7 +27,8 @@ (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 + %destination-directory)) ;;; Commentary: ;;; @@ -36,27 +37,34 @@ (define-module (guix scripts home import) ;;; ;;; Code: +(define %destination-directory + (make-parameter (string-append (getenv "HOME") "/src/guix-config"))) (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) - (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)))) - '())))))) + (define (destination-append path) + (string-append (%destination-directory) "/" 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 + (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) @@ -64,17 +72,24 @@ (define %files-configurations-alist (".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 + (delete-duplicates + (filter-map (match-lambda + ((file . proc) + (let ((absolute-path (string-append (getenv "HOME") + "/" file))) + (if (file-exists? absolute-path) + (begin + (copy-file absolute-path + (string-append + (%destination-directory) "/" file)) + proc) + #f)))) + %files-configurations-alist) + (lambda (x y) + (equal? (procedure-name x) (procedure-name y))))) + + (map (lambda (proc) (proc)) configurations)) ;; Based on `manifest->code' from (guix profiles) ;; MAYBE: Upstream it? From patchwork Sun Oct 10 10:20:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 33730 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 68AC827BBE3; Sun, 10 Oct 2021 11:21:56 +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 EE47427BBE1 for ; Sun, 10 Oct 2021 11:21:55 +0100 (BST) Received: from localhost ([::1]:34318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZVxr-000441-0F for patchwork@mira.cbaines.net; Sun, 10 Oct 2021 06:21:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZVx1-0003ah-V7 for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZVx0-000518-I4 for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mZVx0-0003P2-Ex for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH 2/7] 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: Sun, 10 Oct 2021 10:21: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 Cc: Oleg Pykhalov , Ludovic =?utf-8?q?Court=C3=A8s?= , Andrew Tropin Received: via spool by 50873-submit@debbugs.gnu.org id=B50873.163386122212934 (code B ref 50873); Sun, 10 Oct 2021 10:21:02 +0000 Received: (at 50873) by debbugs.gnu.org; 10 Oct 2021 10:20:22 +0000 Received: from localhost ([127.0.0.1]:54493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwL-0003MY-KL for submit@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:21 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:39738 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwK-0003Lx-0k for 50873@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:20 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1633861214; bh=RylSVc8nuJeWHmXsVlgB+ho4C05ujXWj1OBhUFCaHpA=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=tv7o25WklXQrkSxdiI3OMYWkNnpPT7Wk7mXH0f2SlAC8lseooipjPX9+u+incRQpY HM0gd055AsJlwh/FZ8vNw2V0mXWyCxp2K2MzEVX4AebA21wqYqqLz3kUZeRQs8AH/t td9zgtiePO4xYmrpoQYSFk1HdPaWPF1Yx+o3FkeU= In-Reply-To: References: Message-Id: Date: Sun, 10 Oct 2021 12:20:14 +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 | 43 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index a6ab68a32c..ad926fa202 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -40,15 +40,14 @@ (define-module (guix scripts home import) (define %destination-directory (make-parameter (string-append (getenv "HOME") "/src/guix-config"))) -(define (generate-bash-module+configuration) +(define (generate-bash-configuration+modules) (define (destination-append path) (string-append (%destination-directory) "/" 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 @@ -64,14 +63,16 @@ (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 (modules+configurations) +(define %files+configurations-alist + `((".bashrc" . ,generate-bash-configuration+modules) + (".bash_profile" . ,generate-bash-configuration+modules) + (".bash_logout" . ,generate-bash-configuration+modules))) + +(define (configurations+modules) (define configurations (delete-duplicates (filter-map (match-lambda @@ -85,11 +86,11 @@ (define configurations (%destination-directory) "/" file)) proc) #f)))) - %files-configurations-alist) + %files+configurations-alist) (lambda (x y) (equal? (procedure-name x) (procedure-name y))))) - (map (lambda (proc) (proc)) configurations)) + (map (lambda (proc) (proc)) configurations)) ;; Based on `manifest->code' from (guix profiles) ;; MAYBE: Upstream it? @@ -144,14 +145,14 @@ (define (qualified-name entry) ":" output)))) (manifest-entries manifest)))) (if home-environment? - (let ((modules+configurations (modules+configurations))) + (let ((configurations+modules (configurations+modules))) `(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) + ,@(concatenate (map cdr configurations+modules))) + ,(home-environment-template + #:specs specs + #:services (map first configurations+modules)))) `(begin (use-modules (gnu packages)) @@ -186,18 +187,18 @@ (define name (options->transformation ',options)))) transformation-procedures))) (if home-environment? - (let ((modules+configurations (modules+configurations))) + (let ((configurations+modules (configurations+modules))) `(begin (use-modules (guix transformations) (gnu home) (gnu packages) - ,@(map first modules+configurations)) + ,@(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 Sun Oct 10 10:20:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 33729 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 A491C27BBE3; Sun, 10 Oct 2021 11:21:25 +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 464B227BBE1 for ; Sun, 10 Oct 2021 11:21:25 +0100 (BST) Received: from localhost ([::1]:33736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZVxM-0003dl-Bd for patchwork@mira.cbaines.net; Sun, 10 Oct 2021 06:21:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZVx1-0003aj-Vp for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42965) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZVx0-000519-U6 for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mZVx0-0003PA-RB for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH 3/7] 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: Sun, 10 Oct 2021 10:21: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 Cc: Oleg Pykhalov , Ludovic =?utf-8?q?Court=C3=A8s?= , Andrew Tropin Received: via spool by 50873-submit@debbugs.gnu.org id=B50873.163386123112957 (code B ref 50873); Sun, 10 Oct 2021 10:21:02 +0000 Received: (at 50873) by debbugs.gnu.org; 10 Oct 2021 10:20:31 +0000 Received: from localhost ([127.0.0.1]:54496 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwU-0003Mu-W1 for submit@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:31 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:39774 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwT-0003Mh-F8 for 50873@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:29 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1633861224; bh=VyMj1DdARgasZZuSnNn/LrFF+TrbhGJtnS5Z4Xmjf0U=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=Z+p6DWJzzN2PpgDPVn+rErtaOEBqFj0u+cHImXgp6LPffYaA8D5noz3WhXFumWcfQ 4hOWMX6KYmi/eOiAD4uzn6oIZ639B52E5Rdw9ZknF6m6PVUMD7uDB5xSgEDPARKh+H w/7o4sKF+NzB6UqpokGwUy2WH/D0ftj/U86BnotQ= In-Reply-To: References: Message-Id: <0ecf026f4196f1f3abb10f917e8a566052f70ed6.1633861021.git.public@yoctocell.xyz> Date: Sun, 10 Oct 2021 12:20:23 +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). --- guix/scripts/home/import.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index ad926fa202..96ed710c2d 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -64,7 +64,7 @@ (define (destination-append path) (list (slurp-file-gexp (local-file ,logout))))) '()))) - (gnu home-services bash)))) + (gnu home services shells)))) (define %files+configurations-alist From patchwork Sun Oct 10 10:20:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 33733 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 6A8E627BBE3; Sun, 10 Oct 2021 11:22:15 +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 3269327BBE1 for ; Sun, 10 Oct 2021 11:22:15 +0100 (BST) Received: from localhost ([::1]:34988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZVyA-0004dJ-Bl for patchwork@mira.cbaines.net; Sun, 10 Oct 2021 06:22:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZVx1-0003ak-W8 for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42966) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZVx1-00051A-9b for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mZVx1-0003PH-6V for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH 4/7] guix home: import: =?utf-8?b?RG9u4oCZdA==?= use 'slurp-file-gexp'. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 10 Oct 2021 10:21: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 Cc: Oleg Pykhalov , Ludovic =?utf-8?q?Court=C3=A8s?= , Andrew Tropin Received: via spool by 50873-submit@debbugs.gnu.org id=B50873.163386123712977 (code B ref 50873); Sun, 10 Oct 2021 10:21:03 +0000 Received: (at 50873) by debbugs.gnu.org; 10 Oct 2021 10:20:37 +0000 Received: from localhost ([127.0.0.1]:54499 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwb-0003NF-6W for submit@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:37 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:39804 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwa-0003Mv-91 for 50873@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:36 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1633861230; bh=aQ3MEdOEL7amLbKpRdawZXHaOI8GJ0v6NxyXPJ6ePIE=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=n+dKt0uQGXY8K5cUmN+qGUI6p3pNY4naRSKiCdaV6uEoAf6kKMI7ObIvqTg59Jsk9 fO0o2KX8B+/aaeCv5/1/H+Z56Q43yOHMIcjcaozAE3OElcLT85++95ba27tys5XAo/ LMOtbGtLtW8JVHkvGerc29LVAqbOG+ZlRaXEzjdY= In-Reply-To: References: Message-Id: Date: Sun, 10 Oct 2021 12:20:30 +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 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index 96ed710c2d..21f762f239 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -51,22 +51,18 @@ (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)))) '()))) (gnu home services shells)))) - (define %files+configurations-alist `((".bashrc" . ,generate-bash-configuration+modules) (".bash_profile" . ,generate-bash-configuration+modules) From patchwork Sun Oct 10 10:20:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 33731 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 02DD727BBE3; Sun, 10 Oct 2021 11:21:58 +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 CD7E827BBE1 for ; Sun, 10 Oct 2021 11:21:57 +0100 (BST) Received: from localhost ([::1]:34308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZVxs-00043i-9Y for patchwork@mira.cbaines.net; Sun, 10 Oct 2021 06:21:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZVx2-0003al-0l for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42967) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZVx1-00051C-M9 for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mZVx1-0003PO-Iz for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH 5/7] guix home: import: Delete duplicate modules when importing. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 10 Oct 2021 10:21: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 Cc: Oleg Pykhalov , Ludovic =?utf-8?q?Court=C3=A8s?= , Andrew Tropin Received: via spool by 50873-submit@debbugs.gnu.org id=B50873.163386124012993 (code B ref 50873); Sun, 10 Oct 2021 10:21:03 +0000 Received: (at 50873) by debbugs.gnu.org; 10 Oct 2021 10:20:40 +0000 Received: from localhost ([127.0.0.1]:54502 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwe-0003NV-E3 for submit@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:40 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:39824 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwd-0003N6-8P for 50873@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:39 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1633861233; bh=MrpFKSnBOheEUP1Gsz6KdE+W7u6iL3Oyhb8moemgALU=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=azTt7zoAjbakto9VyYwiG/eimw2nh9nKO6yFnLEL6iLbRJ3gxnbdBt6kNe4z9iiPN SMdvToN0qXCKXXWjh/JHfMSw89AfKeRhZsyYAWUhxLdCio5gc4f3GASoGo/OGAPFSd vH46nGfv/hLPaMPvn7BgFQk8BPVFSEjv2Gf6weIo= In-Reply-To: References: Message-Id: <2814010aadd95c389a54922958d1f3ffedeec106.1633861021.git.public@yoctocell.xyz> Date: Sun, 10 Oct 2021 12:20:33 +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 21f762f239..b892ae3dfa 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -145,7 +145,8 @@ (define (qualified-name entry) `(begin (use-modules (gnu home) (gnu packages) - ,@(concatenate (map cdr configurations+modules))) + ,@((compose delete-duplicates concatenate) + (map cdr configurations+modules))) ,(home-environment-template #:specs specs #:services (map first configurations+modules)))) @@ -188,7 +189,8 @@ (define name (use-modules (guix transformations) (gnu home) (gnu packages) - ,@(concatenate (map cdr configurations+modules))) + ,@((compose delete-duplicates concatenate) + (map cdr configurations+modules))) ,@transformations From patchwork Sun Oct 10 10:20:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 33734 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 5D3CD27BBE3; Sun, 10 Oct 2021 11:22:20 +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 238F727BBE1 for ; Sun, 10 Oct 2021 11:22:20 +0100 (BST) Received: from localhost ([::1]:35188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZVyF-0004ll-8u for patchwork@mira.cbaines.net; Sun, 10 Oct 2021 06:22:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZVx2-0003an-AN for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZVx2-00051k-2j for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mZVx1-0003PW-Vn for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH 6/7] 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: Sun, 10 Oct 2021 10:21: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 Cc: Oleg Pykhalov , Ludovic =?utf-8?q?Court=C3=A8s?= , Andrew Tropin Received: via spool by 50873-submit@debbugs.gnu.org id=B50873.163386124613011 (code B ref 50873); Sun, 10 Oct 2021 10:21:03 +0000 Received: (at 50873) by debbugs.gnu.org; 10 Oct 2021 10:20:46 +0000 Received: from localhost ([127.0.0.1]:54505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwk-0003Nn-La for submit@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:46 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:39852 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwi-0003NP-Nu for 50873@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:45 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1633861239; bh=4HZfDpDQv6G3L+iHcmw74LWqfAhU9l5R7EPesFqqw2E=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=GqUQLCzFhZIMgBLsHeCgCrNyOrSzNpaH3CaLAu8nbCTtJtYYpmNzW7PLyS83i0/ic WNuxIK44M2XIsMLTbmfN+uVOnOkuf6d51IRXiM7keVxPoxVy6fTKmoXQ8A/sjCaA59 0RbC0Xoiy6ftc3V4FUB2zZLA64CzHdAjnOY8866M= In-Reply-To: References: Message-Id: Date: Sun, 10 Oct 2021 12:20:38 +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 b577684eb7..107a76a9d3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -36089,6 +36089,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 Sun Oct 10 10:20:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 33732 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 C718A27BBE3; Sun, 10 Oct 2021 11:22:10 +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 31AF427BBE1 for ; Sun, 10 Oct 2021 11:22:10 +0100 (BST) Received: from localhost ([::1]:34768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZVy5-0004Um-7l for patchwork@mira.cbaines.net; Sun, 10 Oct 2021 06:22:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZVx2-0003ao-Nt for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42969) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZVx2-00051q-FK for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mZVx2-0003Pd-C7 for guix-patches@gnu.org; Sun, 10 Oct 2021 06:21:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH 7/7] 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: Sun, 10 Oct 2021 10:21: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 Cc: Oleg Pykhalov , Ludovic =?utf-8?q?Court=C3=A8s?= , Andrew Tropin Received: via spool by 50873-submit@debbugs.gnu.org id=B50873.163386125813036 (code B ref 50873); Sun, 10 Oct 2021 10:21:04 +0000 Received: (at 50873) by debbugs.gnu.org; 10 Oct 2021 10:20:58 +0000 Received: from localhost ([127.0.0.1]:54508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwv-0003OB-TK for submit@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:58 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:39886 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZVwt-0003Nx-FM for 50873@debbugs.gnu.org; Sun, 10 Oct 2021 06:20:56 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1633861249; bh=TRr6MgO4gfeLa5SQBiDASq5mQZaXwVvBljA0qIiTiec=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=uZMJiQMtR1qb4MqFprIh5MsVWnjj6nw1Y6fHkup5hcIaLJ6VM5NGDeeWFrOFQ9UP1 Mlkj4TJIwnRqNBymDYSgPBPOp1YoK6rOsHX7pxSj7Ca8hX5CAMl82lM6siBPa4lGAx G3o+tFyQIjQJkXSnrMfiF5plOVc0H4m9g4cF22X4= In-Reply-To: References: Message-Id: <197cab14424f4d28ece9e80981d2a4e142dc4791.1633861021.git.public@yoctocell.xyz> Date: Sun, 10 Oct 2021 12:20:49 +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 | 5 +- tests/home-import.scm | 174 +++++++++++++++++++++++++++++++++++ 3 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 tests/home-import.scm diff --git a/Makefile.am b/Makefile.am index 635147efc1..f93199e561 100644 --- a/Makefile.am +++ b/Makefile.am @@ -474,6 +474,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 b892ae3dfa..c68cfb9e78 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -28,7 +28,10 @@ (define-module (guix scripts home import) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:export (import-manifest - %destination-directory)) + %destination-directory + + ;; For tests. + manifest->code)) ;;; Commentary: ;;; diff --git a/tests/home-import.scm b/tests/home-import.scm new file mode 100644 index 0000000000..8d141bba0f --- /dev/null +++ b/tests/home-import.scm @@ -0,0 +1,174 @@ +;;; 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 (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. + +(%destination-directory "/tmp/guix-config") +(mkdir-p (%destination-directory)) + +(define %temporary-home-directory "/tmp/guix-home-import-test") + +(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 (pk (dirname absolute-path)))) + (call-with-output-file (pk absolute-path) + (cut display content <>)))) + + (for-each (match-lambda + ((file . content) (create-file file content))) + (pk 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 + #: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)) + ('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)) + ('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 '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")