From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id gNf6G+T7e2F7TwEAgWs5BA (envelope-from ) for ; Fri, 29 Oct 2021 15:49:24 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id sHhlF+T7e2HBaAAAbx9fmQ (envelope-from ) for ; Fri, 29 Oct 2021 13:49:24 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DA6BD2B589 for ; Fri, 29 Oct 2021 15:49:23 +0200 (CEST) Received: from localhost ([::1]:37536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgSG3-0006Bc-2A for larch@yhetil.org; Fri, 29 Oct 2021 09:49:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgSFi-00069R-UC for guix-patches@gnu.org; Fri, 29 Oct 2021 09:49:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42712) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgSFi-0007IE-Ll for guix-patches@gnu.org; Fri, 29 Oct 2021 09:49:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mgSFi-0003sI-Ha for guix-patches@gnu.org; Fri, 29 Oct 2021 09:49:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH 0/5] Fixes to =?UTF-8?Q?=E2=80=98guix?= home =?UTF-8?Q?import=E2=80=99?= Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 29 Oct 2021 13:49: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: Oleg Pykhalov Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 50873@debbugs.gnu.org, Andrew Tropin Received: via spool by 50873-submit@debbugs.gnu.org id=B50873.163551528214808 (code B ref 50873); Fri, 29 Oct 2021 13:49:02 +0000 Received: (at 50873) by debbugs.gnu.org; 29 Oct 2021 13:48:02 +0000 Received: from localhost ([127.0.0.1]:54258 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgSEj-0003qb-Vo for submit@debbugs.gnu.org; Fri, 29 Oct 2021 09:48:02 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:54992 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgSEg-0003pv-Lu for 50873@debbugs.gnu.org; Fri, 29 Oct 2021 09:48:01 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1635515272; bh=OhNHTQrxRtaxlw4L7rjscm9HlM6DIJq2vWce7TGMzPI=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=WvMWgoEWTDuGN2Zhf7D6aVMQAIC+kGadyIdSJ4nJYQ3fmT+zafqtsw9mUO0pBuo28 5SL4pzSNwVJxJX8+ZOfI9pGG8mAAXvqMv7IU3itKsGjnRp2OWnT5LsyWUoHw9x87rK lz+MVSHiwjiNzRLkRrPd3Bm/MLAq48tkOCF53/oA= In-Reply-To: <87mtnf1zt0.fsf_-_@gmail.com> References: <197cab14424f4d28ece9e80981d2a4e142dc4791.1633861021.git.public@yoctocell.xyz> <87mtnf1zt0.fsf_-_@gmail.com> Date: Fri, 29 Oct 2021 15:47:51 +0200 Message-ID: <87sfwk7xiw.fsf@disroot.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1635515364; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=I5KsXUYHmVZMsV8ZqopgQoiffimTL/ecnDyTK6O0ztM=; b=j+LPcjmb/J9COXmZHDNTa/jj1jPngSW+oeGlFWNQ91E/D2uMuRBVV9GhiHO33B2mh6J8kk 82unRJ7rcJDOM+T2bq60yp5cK8Kfu3jDKaN0dsG0qPepxvnRCYC+ugfDkw8Yyr+rHH6f49 5Z/7pxMe5UpP3BEhzKvfmKAVOQFXhbrZeuu0UWZoaC/Yt7eohMFjEG0wG4NF4Wiu6IwTja uHA2Yt8AbWVTC4jMT698QSxpkgq0vOe6KcItd2O0GTc+wyQ8TjYbd0yyFcnTjyYPsN7no/ TQUhPrjX+oTwBx/MNF8ech1DYn2Ls85nFRD3kzjdf4fich5eASccZBX9BuInbg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1635515364; a=rsa-sha256; cv=none; b=uiuHZYaDUukqqYWMxCsQ7mNWYEX4CpoRRE9JHfRqEFuXW1GJj2aAYn6dSK/k75ZQ0B21FK yPTwd1UFznuD3gTV4ZJ1e6a+mNpkruo2HMDVJfK9n3wiAgrC93RMTSyZ9aOmv9vYaTwn5t ad72e5EJ4mJ0VGdt/7LUEyWjMZe00x/KY/f1fjdvzMRAw+MPxcMsg17o82MvXN8a72vLii hnGuorlMZuvWYHKIIZpqPlH+2q66BdxO1suqTqu0yg5xlbyumn6oK3V4sCpH9m62itA3x0 pVve51/SZYbh+DVYgIMnaMCNW1Z2hzYo5iGQ9t+e5lJLHzi+r2yIpnqeLzRPlg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=WvMWgoEW; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yoctocell.xyz (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.92 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=WvMWgoEW; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yoctocell.xyz (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: DA6BD2B589 X-Spam-Score: -1.92 X-Migadu-Scanner: scn0.migadu.com X-TUID: gNVysRbH5ZPS --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Oct 11 2021, Oleg Pykhalov wrote: > Hi, > > Xinglu Chen writes: > > [=E2=80=A6] > >> +;; 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") > > Better use temporary directory like in tests/opam.scm. > > --8<---------------cut here---------------start------------->8--- > (define-module ... > #:use-module ((guix build syscalls) #:select (mkdtemp!)) > ...) > > (mkdtemp! "/tmp/guix-home-import-test.XXXXXX") > --8<---------------cut here---------------end--------------->8--- Good idea. Out of curiosity: is there any difference between =E2=80=98mkdt= emp!=E2=80=99 and =E2=80=98mkdtemp=E2=80=99 that=E2=80=99s part of Guile? >> + >> +(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 "/" f= ile))) >> + (unless (file-exists? absolute-path) >> + (mkdir-p (pk (dirname absolute-path)))) >> + (call-with-output-file (pk absolute-path) >> + (cut display content <>)))) > > Do we need those 'pk' calls? Nope, just some leftover stuff that I forgot to remove=E2=80=A6 >> +(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")))))))))) > > We should use '%temporary-home-directory' if we use 'mkdtemp!'. I don=E2=80=99t think so, the =E2=80=98bashrc=E2=80=99 file will be copied = _from_ =E2=80=98%temporary-home-directory=E2=80=99 to =E2=80=98%destination-direct= ory=E2=80=99, so this should be =E2=80=98%destination-directory=E2=80=99. >> + >> +(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") > > I tried to use 'guix home import /tmp/foo', where '/tmp/foo' is an empty > directory. Then a pasted the generated code to '/tmp/foo/home.scm' > file. > > --8<---------------cut here---------------start------------->8--- > oleg@guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/hom= e.scm > /tmp/foo/home.scm:487:11: error: service: unbound variable > hint: Did you forget `(use-modules (gnu services))'? > --8<---------------cut here---------------end--------------->8--- > > OK, added missing (use-modules (gnu services)). > > --8<---------------cut here---------------start------------->8--- > oleg@guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/hom= e.scm > /tmp/foo/home.scm:491:29: error: local-file: unbound variable > hint: Did you forget `(use-modules (guix gexp))'? > --8<---------------cut here---------------end--------------->8--- > > OK, added missing (use-modules (guix gexp)) > > --8<---------------cut here---------------start------------->8--- > oleg@guixsd ~/src/guix [env]$ > oleg@guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/hom= e.scm > guix home: error: invalid name: `.bashrc' > --8<---------------cut here---------------end--------------->8--- > > Now, I need to rename .bashrc to dot-bashrc and .bash_profile to > dot-bash_profile. Maybe we should save all dot file with a 'dot-' > prefix by default? Ah, thanks for catching this! I think it would be better to call =E2=80=98local-file=E2=80=99 with the optional =E2=80=98name=E2=80=99 argum= ent like this: (local-file "/some/path/.bashrc" "bashrc") That also means that the =E2=80=9C/some/path/=E2=80=9D part won=E2=80=99t e= nd up as part of the /gnu/store/=E2=80=A6 file name. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmF7+4cVHHB1YmxpY0B5 b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5+dAP/R50fg8PIkhxvJUUXNPNtbg7HuM4 89wVBoz3nfrysKu9VWfhtxXnzmdIE3ckm45DYUKGhADOO4XWVOhBJhdeec76OpNR 3c8sgC60u8ViCO1QGFWc8zxFRN801kmxLTCohNdZVPTwysw3aeCb4rfPexG2VUIe siekV4okGGjPEruU2bkAY60O+xvjpCx3PfEvSyY4bv0xobQ5KBeX+wxm/338BINd GmmRZ1m7AI2yrMwxhtO76HDwqW+IRY5NmMiBp+OhkaixL9fOWM/9n7Xwt3qFdAWa Z0WK38o28RtTUSxg92gXYDs1dajhSwRTm6Wj9jc4FrzY8RBiuh2NDnWYvnvQRdrC YlRLRue2fHpO5nPIAmUPASKruzUZG5otzPZ/EborxTKOyyLNpWoLkhY4kce9bjsq iOOT8jGJEuCA3ZC/3OqfnwNiLQCdNnyOWgNnE6qYEgql2Couq2JgpQNgiAlMLWDU Y0d+8ZLsU7hpqgoTyk7XVGjl/IzEcA2IMDSR/mrFPr2bV446GObePykTryj2a0lC tEqUsQrfyDyL/37ET4Y9HNarZqqoJE6THLEUC38+PLbpy7uNVdFsq/j7HYL+1PH5 REJHsZJ9Dnyz4KBX8n1qMysmlgqHoTr4+5QcjGKekcuqyBoqnT3POjPXUKNdzW2y +gEF50l7Fmi3ScuZ =to73 -----END PGP SIGNATURE----- --=-=-=--