From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id SLP/J6IUbGNlOQEAbAwnHQ (envelope-from ) for ; Wed, 09 Nov 2022 21:59:14 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 6E8tJ6IUbGPqRwAAG6o9tA (envelope-from ) for ; Wed, 09 Nov 2022 21:59:14 +0100 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 24A87A89F for ; Wed, 9 Nov 2022 21:59:14 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ossA4-0006sQ-PP; Wed, 09 Nov 2022 15:59:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ossA2-0006sC-6x for guix-patches@gnu.org; Wed, 09 Nov 2022 15:59:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ossA1-0005eK-Uy for guix-patches@gnu.org; Wed, 09 Nov 2022 15:59:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ossA1-0002Bx-N9 for guix-patches@gnu.org; Wed, 09 Nov 2022 15:59:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Nov 2022 20:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16680275368413 (code B ref 58812); Wed, 09 Nov 2022 20:59:01 +0000 Received: (at 58812) by debbugs.gnu.org; 9 Nov 2022 20:58:56 +0000 Received: from localhost ([127.0.0.1]:41047 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oss9w-0002Bb-7z for submit@debbugs.gnu.org; Wed, 09 Nov 2022 15:58:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oss9u-0002BP-AR for 58812@debbugs.gnu.org; Wed, 09 Nov 2022 15:58:54 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oss9p-0005bd-2S; Wed, 09 Nov 2022 15:58:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=4lVaG61ilgTvnmfhujTMp7mZT4+w/Pn4s2PpbKyzIQQ=; b=hllCSPMWW2LDIZCAgM/I VQpDFjyDnbw3YX0vCYRSQR6ZL4JHKcDJg8FJCyhECOtkYryCFay39JFEXJiW124DQ5odCU8fUYdjT sCVZ0aHscjhROxp1reuh7hwcGN5kRqKH5UAjc7kFXIbgTx6BbjQSRHnJjAsjxVp0fM3iddGISU1xg SiGDr7ZBCE0DdwD0yDEYT0Q7AlH2q3jLVgardOHlViHhol8y/Hl5gruccKEg9EIPETh74psaBqd9+ EPxMqegYhe3KdexwGCN+/fGu+0ftBINlPvHGfqiB/lLm1bhBxkPkjIdjZT4wbEGt9oj/5g8tAtGp3 RJZjyCy7sNSNLg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oss9n-0001TZ-N0; Wed, 09 Nov 2022 15:58:48 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-4-maxim.cournoyer@gmail.com> Date: Wed, 09 Nov 2022 21:58:45 +0100 In-Reply-To: <20221027035100.28852-4-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Wed, 26 Oct 2022 23:50:59 -0400") Message-ID: <87r0ybonei.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1668027554; 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=4lVaG61ilgTvnmfhujTMp7mZT4+w/Pn4s2PpbKyzIQQ=; b=fdrWmWfr4zZG5U3NpEd5bGlrLC/53ud6zpLfzqTWPZdg4u0CF4i0x3UaHVNQegx42NGD76 JOBxl6Zqnjnz02OSCskTKiJgIouZq79c5Zcirnup+Rx/9nSz7vmshuhR5djUsER6PZbLaS SHkhCoXqol+Wws1lR2T3oPGJv3LZeScBhSA/lVZPc7Yjof0aj63JkMpWS8WfRY693/vTHs G4wjlHHTlRZ89X/S06DhousTtbCCBpgXLDHFqhSTGGMQagCGqZZDEnbDKA5pZaQnLbYXWN F9hpZ3PcskQdWMVGL/U60UXLuTINqCFeU2y+tEChORVp6iBgb+rY0HGIDA+IoQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1668027554; a=rsa-sha256; cv=none; b=ePTBZJziabqfgI+vBwacrsretytGlRngvKlUHwM1qcVILXPCWMH7/RvsXq030MaLdjRPzg eXjTi9nqJ0KM54PfwHPyQ6vERhib/eIbnWyKi2mqYJNTUhJMdSD0rdqnMrzOoRY4gRdukr H+ZfSchDYhRc39dna8h1gB/9MwLgVlPi1FzVT6hz7t6bt6QDulHZh2RCFhXQ5GIQOjgHo0 Cj7SXYoFhmpg22ahQM/F0SRRxiGm3nu+byhTA3TVkBJA4h5w0blQ2W59DH83KtbZFbgVKx 8Gx0DXNib1UCK2z4HnAbDUWODsAyurAk/TCjv/I+QlPAhu9stA/pbAk/gB3CWA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=hllCSPMW; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.92 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=hllCSPMW; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 24A87A89F X-Spam-Score: -3.92 X-Migadu-Scanner: scn1.migadu.com X-TUID: O/q1SaqMHfWd Hi, That looks like a useful improvement! Some comments below. Maxim Cournoyer skribis: > +@item --symlink=3D@var{spec} > +@itemx -S @var{spec} > +For containers, create the symbolic links specified by @var{spec}, as > +documented in @ref{pack-symlink-option}. We should refrain from using @ref in sentences (info "(texinfo) @ref"). Instead, I=E2=80=99d write: documented for @command{guix pack} (@pxref{pack-symlink-option}). > (define-module (gnu build install) > + #:use-module ((guix build union) #:select (relative-file-name)) > #:use-module (guix build syscalls) > #:use-module (guix build utils) > #:use-module (guix build store-copy) > @@ -26,6 +27,7 @@ (define-module (gnu build install) > #:use-module (ice-9 match) > #:export (install-boot-config > evaluate-populate-directive > + make-symlink->directives > populate-root-file-system > install-database-and-gc-roots > populate-single-profile-directory > @@ -124,6 +126,22 @@ (define target* (if (string-suffix? "/" target) > directive) > (apply throw args))))) >=20=20 > +(define (make-symlink->directives directory) > + "Return a procedure that turn symlinks specs into directives that targ= et > +DIRECTORY." > + (match-lambda > + ((source '-> target) > + (let ((target (string-append directory "/" target)) > + (parent (dirname source))) > + ;; Never add a 'directory' directive for "/" so as to preserve its > + ;; ownership and avoid adding the same entries multiple times. > + `(,@(if (string=3D? parent "/") > + '() > + `((directory ,parent))) > + ;; Note: a relative file name is used for compatibility with > + ;; relocatable packs. > + (,source -> ,(relative-file-name parent target))))))) I think it=E2=80=99s a case where I would refrain from factorizing because = this procedure, as shown by the comments and the use of =E2=80=98relative-file-n= ame=E2=80=99, is specifically tailored for the needs to =E2=80=98guix pack -f tarball=E2= =80=99. I=E2=80=99d prefer to have a similar but independently maintained variant of this procedure in (guix scripts environment) to avoid difficulties down the road. > +++ b/guix/scripts/environment.scm > @@ -33,8 +33,10 @@ (define-module (guix scripts environment) > #:use-module ((guix gexp) #:select (lower-object)) > #:use-module (guix scripts) > #:use-module (guix scripts build) > + #:use-module ((guix scripts pack) #:select (symlink-spec-option-parser= )) You can turn this into #:autoload so we don=E2=80=99t pay the price when not using =E2=80=98--symlink=E2=80=99. > +++ b/tests/guix-shell.sh > @@ -20,6 +20,8 @@ > # Test the 'guix shell' alias. > # >=20=20 > +. tests/utils.sh > + > guix shell --version >=20=20 > configdir=3D"t-guix-shell-config-$$" > @@ -32,6 +34,21 @@ export XDG_CONFIG_HOME >=20=20 > guix shell --bootstrap --pure guile-bootstrap -- guile --version >=20=20 > +# '--symlink' can only be used with --container. > +! guix shell --bootstrap guile-bootstrap -S /dummy=3Dbin/guile > + > +if has_container_support; then > + # '--symlink' works. > + echo "TESTING SYMLINK IN CONTAINER" > + guix shell --bootstrap guile-bootstrap --container \ > + --symlink=3D/usr/bin/guile=3Dbin/guile -- \ > + /usr/bin/guile --version This should go to =E2=80=98tests/guix-environment-container.sh=E2=80=99, wh= ich has all the container-related tests. Thanks, Ludo=E2=80=99.