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 lY/1BZk1ZGGIeQEAgWs5BA (envelope-from ) for ; Mon, 11 Oct 2021 15:01:13 +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 2G8mAJk1ZGH6NAAAbx9fmQ (envelope-from ) for ; Mon, 11 Oct 2021 13:01:13 +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 514F5DEEE for ; Mon, 11 Oct 2021 15:01:12 +0200 (CEST) Received: from localhost ([::1]:35568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZuvW-0004Va-JJ for larch@yhetil.org; Mon, 11 Oct 2021 09:01:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZuvP-0004R8-2t for guix-patches@gnu.org; Mon, 11 Oct 2021 09:01:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45535) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZuvO-0002UU-Oc for guix-patches@gnu.org; Mon, 11 Oct 2021 09:01:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mZuvO-0002DP-Ls for guix-patches@gnu.org; Mon, 11 Oct 2021 09:01: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: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 11 Oct 2021 13:01: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: Xinglu Chen 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.16339572608376 (code B ref 50873); Mon, 11 Oct 2021 13:01:02 +0000 Received: (at 50873) by debbugs.gnu.org; 11 Oct 2021 13:01:00 +0000 Received: from localhost ([127.0.0.1]:57081 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZuvM-0002Ac-04 for submit@debbugs.gnu.org; Mon, 11 Oct 2021 09:01:00 -0400 Received: from mail-lf1-f53.google.com ([209.85.167.53]:46675) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZuvK-00023X-1N for 50873@debbugs.gnu.org; Mon, 11 Oct 2021 09:00:58 -0400 Received: by mail-lf1-f53.google.com with SMTP id i24so71769922lfj.13 for <50873@debbugs.gnu.org>; Mon, 11 Oct 2021 06:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=N9oM6jLwn+levB3mCIr0WAoLQCtg0GErxOmIfvp2iqU=; b=lN+zq/HMjeWxWRGMH+lGkNNSdVWmdhQresWuceKbi9iWpfTYekulxiIaqRm7NbgKBE WiFna5dbhvoCDVjrpDl731ZLtpEJDAIu8K2K8oE5LMekiHs8FCxZOO4ezDpjhtYuaRrd Wt4jLEQ1FJGYl0Z5kQcVEFvdc2Spr9eLrrCroVXzBL++tCBF+Yk3m2T/sd9zrIIYbVkF m47YX9H2O83w7tU72qjVXYA/1Iy0okiNgz1TDO2/H8pHuDh1ect2E72yt+z6MHQP2Sob ZeCaWjLRfXgRqC2i4OuaxdKJ3GjlkAGaY/2gQssLGVpuNPlsKp9lLlhkx+5xbKQInV8t sBtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=N9oM6jLwn+levB3mCIr0WAoLQCtg0GErxOmIfvp2iqU=; b=v8PQz2VZDbKeFM7vCVXQiseUDj/ECGmzRLnN45SNllTaectmhs1pOf9sRF/REYMFJD KYB/Pm3NDSlkvk6jsgjpDdir8KH8Yr4rgUhdUmh61REiBubVY1ZaFdZ7O/EGthfFXHkr wvJJua5+TD9ZaxpuWefcUi+mnUc2qBf+GIv5McvIRg8D2l8NahtV/AHV8fBGedx6pxNQ bVlZMTN1JWbgftgTlv/XfcXAp3D0bWdeSGfmea8yDTlshMaIaHRw91hnOWU+seqq/dzv rqjSxUJVYW/ikv8E+ROs/z3W4k+g3+ZdAjQLZ3ygNAImELHkvaV2AQl7EGPgYj+IEZja sNXw== X-Gm-Message-State: AOAM531y04xiS5q10BpXHdQ+COWYSmsFEOS1/oncvdAsWBwtRmtVYNiU VxZweyVfkxVhBgvFGkZ3y2g= X-Google-Smtp-Source: ABdhPJyjMwAPxhiFcPuLOhmxKac9a8C1SAY6IBoBp2Uv/5w8Z+ibOtznTgBDrIyxdzdEzd8lBGXviQ== X-Received: by 2002:a2e:a415:: with SMTP id p21mr132329ljn.384.1633957245188; Mon, 11 Oct 2021 06:00:45 -0700 (PDT) Received: from guixsd ([88.201.161.72]) by smtp.gmail.com with ESMTPSA id m3sm729959lfh.2.2021.10.11.06.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Oct 2021 06:00:44 -0700 (PDT) From: Oleg Pykhalov References: <197cab14424f4d28ece9e80981d2a4e142dc4791.1633861021.git.public@yoctocell.xyz> Date: Mon, 11 Oct 2021 16:00:43 +0300 In-Reply-To: <197cab14424f4d28ece9e80981d2a4e142dc4791.1633861021.git.public@yoctocell.xyz> (Xinglu Chen's message of "Sun, 10 Oct 2021 12:20:49 +0200") Message-ID: <87mtnf1zt0.fsf_-_@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; 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=1633957272; 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=N9oM6jLwn+levB3mCIr0WAoLQCtg0GErxOmIfvp2iqU=; b=Tm4TXyc3ZQ4NTsqkLO0rJdETmc+T12DyhIJ8eBehSzFG+3lK3C/R/Rfei2eUtYhmrMPqZr +M5oYpYj+hR6ILFPbuGcl5HgFmE4OtDiojOTazJXVg/ZVb8G75UiS+AIch+p9195ylW2BZ HDVXccWs3oy4tF+BKtUIm3nZ6cui+cAR4MMCH8Y5rnf9pt0PZwohmm3yOIi/Dl5WerKrW9 0QOS1SNinK+6fINp9OX1ORoXsHdTFcGuKGWLeXsoT1gocvk+aHI84Jjm6E7rGUGlCT0Dv5 IrVlx/DV4ZRijtjSfL8NJ493X/g8XtXE5cc2flg/Sm2GEUcTucUXg9/e67D5dA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633957272; a=rsa-sha256; cv=none; b=WH8YPxLX2XgA8ZLEcgJiYJHg42rp9RD2kn+vnvrbaZPKJINpegSNcnHHuKxBBNzQRx0Y7I IEPf1ikR/RPxPMe2fkRDez8/2Ry5Gw0WaAX5ih5ze2w6hOHD+xk17xUFgRJuZ7QD07gPNv K6RnpF3Tfo0+arqzQGrWlS0HjlnN1FRWfN+YkWCYKmoS92uyGYgMrc3YqxS58kHV4CJJkl BTH5JdTYzMiE8CiW91Ah0aC/xmTNwU9tT33KBucsWUCCleXsbThIsvx862XXRId9mbxG/K IxEk0MGz646eV1v1gfEPMZJgtpeoJqH4q17yms2bWVE+U5LZEB09LaGJc6MF7A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="lN+zq/HM"; 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: -3.81 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="lN+zq/HM"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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: 514F5DEEE X-Spam-Score: -3.81 X-Migadu-Scanner: scn1.migadu.com X-TUID: pI8vjz33jWIh --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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. =2D-8<---------------cut here---------------start------------->8--- (define-module ... #:use-module ((guix build syscalls) #:select (mkdtemp!)) ...) (mkdtemp! "/tmp/guix-home-import-test.XXXXXX") =2D-8<---------------cut here---------------end--------------->8--- > + > +(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 "/" fi= le))) > + (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? [=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!'. > + > +(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. =2D-8<---------------cut here---------------start------------->8--- oleg@guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/home.= scm /tmp/foo/home.scm:487:11: error: service: unbound variable hint: Did you forget `(use-modules (gnu services))'? =2D-8<---------------cut here---------------end--------------->8--- OK, added missing (use-modules (gnu services)). =2D-8<---------------cut here---------------start------------->8--- oleg@guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/home.= scm /tmp/foo/home.scm:491:29: error: local-file: unbound variable hint: Did you forget `(use-modules (guix gexp))'? =2D-8<---------------cut here---------------end--------------->8--- OK, added missing (use-modules (guix gexp)) =2D-8<---------------cut here---------------start------------->8--- oleg@guixsd ~/src/guix [env]$ oleg@guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/home.= scm guix home: error: invalid name: `.bashrc' =2D-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? Oleg. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAmFkNXsUHGdvLndpZ3Vz dEBnbWFpbC5jb20ACgkQFn+OpQAa+py98BAAw2qrJNXtEuNXJyUws9obypmDH2aB NtX29V0AjXhmVpoY60rv41I8OVeammAMLAX9974u8Lka1vNfiVKd14JkHqRutKur I6qPbgBjUCI0MSDwl2MrUbq9y/QMw9fmo/PSY+TXE6Zfzg7hN2XLMllwfKVSD5JV rSE67+OybUDPI2Nopx6TEJydwTGdBiRVQBWo4nw7fhqzWYXQtkNoe/BeoAwoybLF wW8+rL9JyISch66f2TSduyVcHXp8F07r9hzCb9S9PqpiQ6EtaVUJC37uJ/jW5b3a Q7r/EVygZMD4bHX5qz5gOe+Cu5HoXUuz/07q2S+E9spjZ+1hVGUltEm6oPU8xLjU /FN9dbMuSLZfzew3UoE6NqNa4bNDjSM5LRO2ZIi3E9N8WCj5ggJVgXziEsns94Aa D0obuR9lPATcXzK2XTqdpGK1jdvDKeaNfZQA7gnkIkV1TMbj2p2u2dFVdaM5zjcU tWOLC/6ypLZMlo+g/RygeMWWAW2mba2Yz+05kzaIxucgXxx51fYJWVX8LBuR5+XM pQwwB6W9jEicJu07RFfE357mj4LPuRhfV071ngKi4UTtoz+MxYE9TE6pu9BGPp8z qo3UU9zODk4HZD4NL2dkQEOTesoWXfIdW8MYoxhaKgxYMmEKxg8eLBPopu4EUJE2 gmEGq1y7C00Eb/k= =mkRy -----END PGP SIGNATURE----- --=-=-=--