From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id cFhWHeNrbGPLYAAAbAwnHQ (envelope-from ) for ; Thu, 10 Nov 2022 04:11:31 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id gBJ9HeNrbGOCKwAA9RJhRA (envelope-from ) for ; Thu, 10 Nov 2022 04:11:31 +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 2CAC83FFD4 for ; Thu, 10 Nov 2022 04:11:27 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osxy5-00088k-5D; Wed, 09 Nov 2022 22:11:05 -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 1osxy3-00088H-3W for guix-patches@gnu.org; Wed, 09 Nov 2022 22:11: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 1osxy2-0008Sb-Oe for guix-patches@gnu.org; Wed, 09 Nov 2022 22:11:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1osxy2-0003E7-5d for guix-patches@gnu.org; Wed, 09 Nov 2022 22:11:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Nov 2022 03:11:02 +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: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166804984812381 (code B ref 58812); Thu, 10 Nov 2022 03:11:02 +0000 Received: (at 58812) by debbugs.gnu.org; 10 Nov 2022 03:10:48 +0000 Received: from localhost ([127.0.0.1]:41508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osxxn-0003Dc-Qq for submit@debbugs.gnu.org; Wed, 09 Nov 2022 22:10:48 -0500 Received: from mail-qt1-f170.google.com ([209.85.160.170]:43580) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osxxm-0003DQ-AW for 58812@debbugs.gnu.org; Wed, 09 Nov 2022 22:10:46 -0500 Received: by mail-qt1-f170.google.com with SMTP id a27so327420qtw.10 for <58812@debbugs.gnu.org>; Wed, 09 Nov 2022 19:10:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=gFhpnLHygsw9Jxxct5LBxMucG6Itgdd3ZDonwCDctw0=; b=R40W61H9Z/Nn88+jKIF84mehoDQnnocXXY3307MkDHIx14znZC7Umr8BqsqfBZhDA0 6bcv7OTNfnhirXAiicz9n7NnAkfhCvJD+LwzYJcCtojAe9uLRWmw3xlCl3FP2j17xChY nN1cZ7uVUShErbC/RfFhtbnKYI8jnEBZ8E1qrffbw8+2zx3iMb+F4HfO0uymyYdCbPuC pKyiu5EP3Bq+u4lmFs9xDPnurUF00IYCkkM0d64ak11rZq1OU+YFdDA+uvps/FTUevyC OzN/0jWy7bEHEXT6yaOuvEoY2ZJUumTrcPZ0ow+vZCcqXGQfy02pf3b3PVdCeO9ky+SB EFsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=gFhpnLHygsw9Jxxct5LBxMucG6Itgdd3ZDonwCDctw0=; b=vOSnF6ayLN0+/3dpU6wGhL4iFNlaifnNg7LlcNp7YtaPl7ETXbsaeQbFBT+NsyoOwn yZTxqy8T/nmQsQXc1RhbUOR6H9qj7DQ2b/94axZi9leIEtYU6Tqmcbh2oRFjeld6B9NH FZ5R1EmahWqYuQeLdQYEbPpzEEWGowFIoTZUls582A7PAtF9/MUdPW5Lc1fr7QVQ1irT jnWOyad6H7wh7Ay3gGR8u6XAtB0KIHII4c5YKLVYTIu3lHgcNf/UWTQf5bog6vlLZFri JYEQcuVsQ5oc1cTlgKvXESarswyyKcCCJZVCnmW/M6x49DJUYZaHnqgWTkWwPm+H7Bvn YlPg== X-Gm-Message-State: ACrzQf1a+YHJ2KAb8kYNggbP2ZQx08d6xesbUkJIJziRenHba0YLO7AY gynSc9au8aTp0eQ5hs0Kxvz1VK/xHXU= X-Google-Smtp-Source: AMsMyM6xe0tQiwdJ92Sl7pGM+24AL3/uLQ1Z9RZt9xL8bNpIlp1Nu5VHgzBPcmol1M+VeBL8jgHv5g== X-Received: by 2002:a05:622a:1902:b0:39c:efc6:b3cf with SMTP id w2-20020a05622a190200b0039cefc6b3cfmr49440149qtc.527.1668049840401; Wed, 09 Nov 2022 19:10:40 -0800 (PST) Received: from hurd ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id w27-20020a05620a0e9b00b006ee949b8051sm11818544qkm.51.2022.11.09.19.10.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 19:10:39 -0800 (PST) From: Maxim Cournoyer References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-4-maxim.cournoyer@gmail.com> <87r0ybonei.fsf_-_@gnu.org> Date: Wed, 09 Nov 2022 22:10:38 -0500 In-Reply-To: <87r0ybonei.fsf_-_@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Wed, 09 Nov 2022 21:58:45 +0100") Message-ID: <87fsery05t.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (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=1668049887; 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=gFhpnLHygsw9Jxxct5LBxMucG6Itgdd3ZDonwCDctw0=; b=QEe1NNsxz91uwXqNfVA+OQ+j14QgfNU3qUEzebXSDLXsqtPhlNYY2iDytzPfJWkpveJxHk TD6j748SU+qIplyZxBsoycTMncL84rV2m/hCH+LjC/UEOK7SPfjMEWZA4j7hA09D0vqbZk b7JBBW6UTpCCN4o2nzDUAbca9rqw7Yw2VKFhE0Kb8vcoDlvA28i1wgwIM6nM0b7og/STln 5oEt0Oen2aVhiVY5D2kENgNg+0UL2NWZBVP/E55XMz/rn5bdrMweFLgthRm4AEOeU4BV5S dqKKk0IPi9IQyIIvQumYlbnNE3XROgfTTBK77bZc2hwUEJRdNoIRwgKEnrY1yg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1668049887; a=rsa-sha256; cv=none; b=nZPSGdH87Cctouig2B5ktYn8N5uxYmCnvMrjDkTeJPrhWl8HUTKVsk6S/aEz3LDsr4Pfbb 7eBtgpefjXAfVqn5moCWrebbpzyECzbsR92woGsud7U5hwhGRs2Q+iTysy4heMxJ3/viCz EMZwbCcxx1pUgj5J5VGhNq3Pw1zKpZZAvP3OWJf7LT0cLwq21wg7bVRk0tQNDhfohFFYBj hXI0e8G6/F44SI1kXJt7vZ38krzxCMKK35EPaJakAWwdeQD+Tjqa+kEOZOGBtEZNvmovNI xvmmvBssHsq71vqEnqY6UExyCe09dfgDzH1vSE2829KO4s797wcsIaQihcZezw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=R40W61H9; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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: 7.47 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=R40W61H9; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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: 2CAC83FFD4 X-Spam-Score: 7.47 X-Migadu-Scanner: scn1.migadu.com X-TUID: e8SNM6/GwjuT Hi Ludo! Ludovic Court=C3=A8s writes: > Hi, > > That looks like a useful improvement! Some comments below. Thanks! > 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}). I've heard that from you before, but is there a reason against? I like to know the rationale for doing things a certain way, lest I forget :-). >From info '(texinfo) @ref': --8<---------------cut here---------------start------------->8--- 6.6 '@ref' =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D '@ref' is nearly the same as '@xref' except that it does not generate a 'See' in the printed output, just the reference itself. This makes it useful as the last part of a sentence. For example, For more information, @pxref{This}, and @ref{That}. produces in Info: For more information, *note This::, and *note That::. --8<---------------cut here---------------end--------------->8--- >> (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))))) >> >> +(define (make-symlink->directives directory) >> + "Return a procedure that turn symlinks specs into directives that tar= get >> +DIRECTORY." >> + (match-lambda >> + ((source '-> target) >> + (let ((target (string-append directory "/" target)) >> + (parent (dirname source))) >> + ;; Never add a 'directory' directive for "/" so as to preserve i= ts >> + ;; 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 becaus= e this > procedure, as shown by the comments and the use of =E2=80=98relative-file= -name=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. I considered to duplicate it, but I opted to reuse it in the end because I care that the behavior is exactly the same between the two actions (guix shell --symlink vs guix pack --symlink). If the way we handle this is to be changed in the future, I'd want both to be changed at once, so they remain consistent. Does this make sense? >> +++ 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-parse= r)) > > 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. Done! Could Guile simply always use lazy loading (autoload by default)? Otherwise, when is it OK to use autoload and when is it not? >> +++ b/tests/guix-shell.sh >> @@ -20,6 +20,8 @@ >> # Test the 'guix shell' alias. >> # >> >> +. tests/utils.sh >> + >> guix shell --version >> >> configdir=3D"t-guix-shell-config-$$" >> @@ -32,6 +34,21 @@ export XDG_CONFIG_HOME >> >> guix shell --bootstrap --pure guile-bootstrap -- guile --version >> >> +# '--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, = which has all > the container-related tests. Done, for the "has_container_support" conditional tests. Thanks for taking a peek! Maxim