From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 8HUiMTWQW2HcbAEAgWs5BA (envelope-from ) for ; Tue, 05 Oct 2021 01:37:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id mM/oLDWQW2FSMgAA1q6Kng (envelope-from ) for ; Mon, 04 Oct 2021 23:37:25 +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 97B00C192 for ; Tue, 5 Oct 2021 01:37:21 +0200 (CEST) Received: from localhost ([::1]:38370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXXD8-0007AN-9B for larch@yhetil.org; Mon, 04 Oct 2021 19:17:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXXAl-0005Co-3x for guix-patches@gnu.org; Mon, 04 Oct 2021 19:15:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55291) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mXXAk-0008OB-So for guix-patches@gnu.org; Mon, 04 Oct 2021 19:15:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mXXAk-0006eg-Ow for guix-patches@gnu.org; Mon, 04 Oct 2021 19:15:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists. Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 04 Oct 2021 23:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50967 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 50967@debbugs.gnu.org Cc: Oleg Pykhalov , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Xinglu Chen , Andrew Tropin Received: via spool by 50967-submit@debbugs.gnu.org id=B50967.163338925725474 (code B ref 50967); Mon, 04 Oct 2021 23:15:02 +0000 Received: (at 50967) by debbugs.gnu.org; 4 Oct 2021 23:14:17 +0000 Received: from localhost ([127.0.0.1]:38597 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mXX9t-0006cZ-If for submit@debbugs.gnu.org; Mon, 04 Oct 2021 19:14:17 -0400 Received: from mail-lf1-f51.google.com ([209.85.167.51]:33753) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mXX9k-0006bS-0G for 50967@debbugs.gnu.org; Mon, 04 Oct 2021 19:14:04 -0400 Received: by mail-lf1-f51.google.com with SMTP id y23so38932772lfb.0 for <50967@debbugs.gnu.org>; Mon, 04 Oct 2021 16:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VWOMu/1y352jN1iQIk1dmRNhHy+2lVBDKGyIJsYzPUE=; b=lxYZemNY3leAxyhEtPN31NTfiFxWiNQCsYk4ALqwzHEjNJe9hd3P/GPNLd0BEIpFfP 35APGVkTTpX0QrleTkqv1wvxrhLpKtheHNDy2u5nmkVGFeKk3bUcywy+yHtpBztKue8U av9OCQJgZQE4JD95KV3ZncVHZVc5rR85fMaSGvpas7iaKxTOZyXKjQj/KuNAQZT3hxc9 a9o67vGfv7gkCwX84u5zWNvczBeAu/qH1tQipdUxG9BakSvXEvg6zSE+qN9aTKLKG1/4 LaWcCSwXVNUjD8qtZb2F5fYt7ESK+9stvbkQ/osdbrygxW3MOnk/Qpzlk7L2nLQG0PuM M28A== 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VWOMu/1y352jN1iQIk1dmRNhHy+2lVBDKGyIJsYzPUE=; b=fw4x9ikti35nLffIYMBsKtG0J02sJFL3mpR0RO34JN5pXtIRka6SH5kikBMPD7sZzE 9N6qezomHchsdneOdWGh5vE4las6f9xxEKnX4S0uaZX+d0Bfc63xvZKYERZdGjeSmYlO 3C2SalTQaYLXiS7Ym7WkBLMBdPtIcsHSzBuB9vtqimhp0Hzd4k1FJO7xbFqq95mjIAE1 MCnIkDTKQ/TeU12PVOHDPoXXT4RZ8wm1oif+e0Nhicak5SfI+Nz3jptpTNVoGn2LyFF3 b4TOC1VGhGRFm0OD8DL4PnMFEwLvI6hD8fozKsf91Rdre+0nWOz2GFKXQIUoYF9+VCJg PaLw== X-Gm-Message-State: AOAM532qvBpUWN0nPFhLpoeQJ4FiB/cfFB3OkYUWZWxEaESFiiQefsEo cJovfUc/bfEQbYTaRb896WgCqorJspA= X-Google-Smtp-Source: ABdhPJza8Rgm7Ru2T+8LvkhXM8AVaMZpWnUnnLUMP5Ey5iF8ppwYphW9eu5am8BuYOjzEvbnDsfEuA== X-Received: by 2002:a05:6512:12c7:: with SMTP id p7mr16856894lfg.328.1633389234073; Mon, 04 Oct 2021 16:13:54 -0700 (PDT) Received: from localhost.localdomain ([88.201.161.72]) by smtp.gmail.com with ESMTPSA id h4sm1736542lft.184.2021.10.04.16.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 16:13:53 -0700 (PDT) From: Oleg Pykhalov Date: Tue, 5 Oct 2021 02:13:31 +0300 Message-Id: <20211004231331.5269-3-go.wigust@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004231331.5269-1-go.wigust@gmail.com> References: <87h7dwq4cb.fsf_-_@gnu.org> <20211004231331.5269-1-go.wigust@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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=1633390642; 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: content-transfer-encoding:content-transfer-encoding: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=VWOMu/1y352jN1iQIk1dmRNhHy+2lVBDKGyIJsYzPUE=; b=eBiSgFIkxiXYmGf6GjHb8g4gfxjABWbkqmvAxVvZqdV8EX10CUnXf4BvLkyShJcUI805O1 FZe27b2+uXSZ1K19KTohHBNEAnUtdvMhZK+PSMCudnEaUF597Y0BSJ7RHEVzhsaYnJ42um xyW/b072uOxYG4tEWTVuQCHuifYSzEPfYsFxagJlSXaUcLVVIzzTJZb4k+3QkQP/W3Plc2 bxPfV56/71+MN38eXttOCrTys1yLeeDUxo6LrMqEibUEBFoPoH1EE3qrK1CFa30Fz5F/IM gnaRWRAw7fyTPxxU78R5NFXQr/yCnxvEmlX1za1/MevcShAcNUUTvZy1Toa4zQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633390642; a=rsa-sha256; cv=none; b=UZVflX/11+9noMadbd2AlQmN09h8PKC+RPj79/0S4PQP/Dbma6wdlaoxf+JWaq//MARt3q /1fm22OOfguWp00PjdDOjW20iLnKFHnBZw/3ReaiP2jzhQew6hHe3Vhg8rvj1ef8YPWAHG Bd9pgAOekcEbo3ztA2E2/K93W1QI7LWQ9p4VHHwylJlz20DWoCX99FO5HWbwm8Hg0sV6Pi xC9NQS/zOruCeNP3IhTCVWeVuNHQPkxs8vney7hPUryMoge9K/KCZu4kee84KMnFz2Iucy zryTpxuWMRB7DI34TTKd1jFgK98HR9D1d+fr96uTayiwLA2v57bzTMjEY3l8vw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=lxYZemNY; 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-Spam-Score: 0.38 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=lxYZemNY; 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: 97B00C192 X-Spam-Score: 0.38 X-Migadu-Scanner: scn1.migadu.com X-TUID: eSdJhHr32fXO * guix/scripts/home.scm (process-action): Make sure profile directory exists. * tests/guix-home.sh: New file. * Makefile.am (SH_TESTS): Add this. --- Makefile.am | 1 + guix/scripts/home.scm | 2 ++ tests/guix-home.sh | 73 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 tests/guix-home.sh diff --git a/Makefile.am b/Makefile.am index b66789fa0b..5bf2567dc8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -546,6 +546,7 @@ SH_TESTS = \ tests/guix-package-aliases.sh \ tests/guix-package-net.sh \ tests/guix-system.sh \ + tests/guix-home.sh \ tests/guix-archive.sh \ tests/guix-authenticate.sh \ tests/guix-environment.sh \ diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index 75df6d707d..115dfadb57 100644 --- a/guix/scripts/home.scm +++ b/guix/scripts/home.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Andrew Tropin ;;; Copyright © 2021 Xinglu Chen +;;; Copyright © 2021 Oleg Pykhalov ;;; ;;; This file is part of GNU Guix. ;;; @@ -179,6 +180,7 @@ ACTION must be one of the sub-commands that takes a home environment declaration as an argument (a file name.) OPTS is the raw alist of options resulting from command-line parsing." (define (ensure-home-environment file-or-exp obj) + (ensure-profile-directory) (unless (home-environment? obj) (leave (G_ "'~a' does not return a home environment ~%") file-or-exp)) diff --git a/tests/guix-home.sh b/tests/guix-home.sh new file mode 100644 index 0000000000..e79982b7f7 --- /dev/null +++ b/tests/guix-home.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +# GNU Guix --- Functional package management for GNU +# Copyright © 2021 Oleg Pykhalov +# +# This file is part of GNU Guix. +# +# GNU Guix is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# GNU Guix is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Guix. If not, see . + +# +# Test the 'guix home' using the external store, if any. +# + +guix home --version + +NIX_STORE_DIR="$(guile -c '(use-modules (guix config))(display %storedir)')" +localstatedir="$(guile -c '(use-modules (guix config))(display %localstatedir)')" +GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket" +export NIX_STORE_DIR GUIX_DAEMON_SOCKET + +# Run tests only when a "real" daemon is available. +if ! guile -c '(use-modules (guix)) (exit (false-if-exception (open-connection)))' +then + exit 77 +fi + +STORE_PARENT="$(dirname "$NIX_STORE_DIR")" +export STORE_PARENT +if test "$STORE_PARENT" = "/"; then exit 77; fi + +test_directory="$(mktemp -d)" +export test_directory +trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT + +( + cd "$test_directory" || exit 77 + + cat > "dot-bashrc" <<'EOF' +# dot-bashrc test file for guix home +EOF + + cat > "home.scm" <<'EOF' +(use-modules (gnu home) + (gnu home-services) + (gnu home services shells) + (gnu services) + (guix gexp)) + +(home-environment + (services + (list + (service home-bash-service-type + (home-bash-configuration + (guix-defaults? #t) + (bashrc + (list + (local-file (string-append (dirname (current-filename)) + "/dot-bashrc"))))))))) +EOF +) + +guix home reconfigure "${test_directory}/home.scm" -- 2.33.0