From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 0JGDECoEXGG71QAAgWs5BA (envelope-from ) for ; Tue, 05 Oct 2021 09:52:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id cHY6DCoEXGF5YAAAB5/wlQ (envelope-from ) for ; Tue, 05 Oct 2021 07:52:10 +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 BEC385837 for ; Tue, 5 Oct 2021 09:52:09 +0200 (CEST) Received: from localhost ([::1]:57118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXfFA-0001zb-RC for larch@yhetil.org; Tue, 05 Oct 2021 03:52:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXfF4-0001zS-EE for guix-patches@gnu.org; Tue, 05 Oct 2021 03:52:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55645) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mXfF4-00071I-6o for guix-patches@gnu.org; Tue, 05 Oct 2021 03:52:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mXfF4-00075p-5c for guix-patches@gnu.org; Tue, 05 Oct 2021 03:52:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50960] [PATCH 04/10] DRAFT shell: By default load the local 'guix.scm' or 'manifest.scm' file. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 05 Oct 2021 07:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50960 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 50960@debbugs.gnu.org Received: via spool by 50960-submit@debbugs.gnu.org id=B50960.163342029627236 (code B ref 50960); Tue, 05 Oct 2021 07:52:02 +0000 Received: (at 50960) by debbugs.gnu.org; 5 Oct 2021 07:51:36 +0000 Received: from localhost ([127.0.0.1]:38958 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mXfEd-00075C-Km for submit@debbugs.gnu.org; Tue, 05 Oct 2021 03:51:35 -0400 Received: from albert.telenet-ops.be ([195.130.137.90]:34258) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mXfEb-000754-GY for 50960@debbugs.gnu.org; Tue, 05 Oct 2021 03:51:34 -0400 Received: from ptr-bvsjgyjmffd7q9timvx.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by albert.telenet-ops.be with bizsmtp id 27rY2600M0mfAB4067rYF2; Tue, 05 Oct 2021 09:51:32 +0200 Message-ID: <1e4e9ace6c74c37f2f0aaba354ad89d642f81e2b.camel@telenet.be> From: Maxime Devos Date: Tue, 05 Oct 2021 09:51:32 +0200 In-Reply-To: <20211002102240.27815-4-ludo@gnu.org> References: <20211002102240.27815-1-ludo@gnu.org> <20211002102240.27815-4-ludo@gnu.org> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-HwFhDEgklzBYqVcJRbH8" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1633420292; bh=QjJ3O2HW1C43peeYRNET711XRnCnt9Xt9jEm+A0cwJ4=; h=Subject:From:To:Date:In-Reply-To:References; b=hgg53DpZ6AsCAwUKzhXqJT7OvP72PqM8r/13SP5LCgaOt/cGI4Ymn6mMN/CPsu97O Ln4I7zciOiLPXlw09ISrVe9vCv8H8FqkcK7YY6XdmZDYquDphpKfpohTgwoqdYw1ns aKzAU2/gdkPqC80rUnGV5mmWuiQzr1eYSNT3sBVwUbAJlxure2UHhRlCn5xa/tpNWK bMPUhG9Wdo98l5Xjvb9EcSepEqpXCSmmuep4fAdIx/yTRy++OvJu/OTnwJjhnkMoHj DbcadWiisLtPi5Ic+ekPz0CdzzQf25GT+Tuowtv/qbuPgjtqbuB8CdVc246Q4XRKpp PrZ31efyhdw7g== 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=1633420329; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=QjJ3O2HW1C43peeYRNET711XRnCnt9Xt9jEm+A0cwJ4=; b=PQ8euTjF91eTnXD9UN0oXJYQFo3CZu5cuG1WUQm60bJQYGJDHjfEKc2/n8J57VGMJMxKZH cnsNB6EavQWG8UAv5Dh5DnzBaEkvqtWsnPtGK0D0KjczDxF9H/bZzp9bD9jPuerI4Sdozt 4pKhzMGnxWy8VpeS7+TNSLOqFwYJEqbCcOw/A2adl8Bzj2MTRSTT3YAyJMR1j26NEmkz8b RgCmbUO+tMqrbdd9hfp0yP7i8gOSKs71rw7SzGoxc+KTCVDtg20cLn8HZS66BoNaRBMIf3 sAkUKcjX4uKR6EZZf1E3UBZlykbna+NZnxWnBF5XtZCeQAcOiWIO5ELYFSRFDA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633420329; a=rsa-sha256; cv=none; b=DnptVwTx/Q0nLT9F7a7LhZf+X6fdNbceTSfq0eXayaD82kKTaF8tTIKWxZz2JGiRdoFsZ5 GHqAMl7YF91V/VLLuPOAtEytu9qdxjkuzWrvbja81rVNiPvaylrlkQ5WONqpw7JT5fy6wl lHNuTQK+fxs1U/gOZWnjqLFCOvpPnzhaQnO6S4qR/ZwoOCil65aszeEGypiKTwTDLlqMTE F2l1ymWQL4BMs9+E+x3UNbQNf95XwC0pbKy5v+CLac/70oc5AGeBUxYPjvTFY6JxezoOyD e5FNWTr92cvyizLKA/d6XFNwlTZCwwolca+yT7o4XlOqUdHD9NjDk0FuoNjiHw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b=hgg53DpZ; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (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: -3.91 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b=hgg53DpZ; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (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: BEC385837 X-Spam-Score: -3.91 X-Migadu-Scanner: scn1.migadu.com X-TUID: HbX98z+zXC00 --=-HwFhDEgklzBYqVcJRbH8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s schreef op za 02-10-2021 om 12:22 [+0200]: > DRAFT: Add doc. >=20 > * guix/scripts/shell.scm (parse-args): Add call to 'auto-detect-manifest'= . > (find-file-in-parent-directories, auto-detect-manifest): New procedures. > * tests/guix-shell.sh: Add test. > --- > guix/scripts/shell.scm | 44 ++++++++++++++++++++++++++++++++++++++++-- > tests/guix-shell.sh | 16 +++++++++++++++ > 2 files changed, 58 insertions(+), 2 deletions(-) >=20 > diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm > index 6a4b7a5092..2f15befbd3 100644 > --- a/guix/scripts/shell.scm > +++ b/guix/scripts/shell.scm > @@ -22,6 +22,8 @@ > #:autoload (guix scripts build) (show-build-options-help) > #:autoload (guix transformations) (show-transformation-options-help) > #:use-module (guix scripts) > + #:use-module (guix packages) > + #:use-module (guix profiles) > #:use-module (srfi srfi-1) > #:use-module (srfi srfi-26) > #:use-module (srfi srfi-37) > @@ -121,13 +123,51 @@ interactive shell in that environment.\n")) > ;; The '--' token is used to separate the command to run from the rest= of > ;; the operands. > (let ((args command (break (cut string=3D? "--" <>) args))) > - (let ((opts (parse-command-line args %options (list %default-options= ) > - #:argument-handler handle-argument))= ) > + (let ((opts (auto-detect-manifest > + (parse-command-line args %options (list %default-option= s) > + #:argument-handler handle-argument)= ))) > (match command > (() opts) > (("--") opts) > (("--" command ...) (alist-cons 'exec command opts)))))) > =20 > +(define (find-file-in-parent-directories candidates) > + "Find one of CANDIDATES in the current directory or one of its ancesto= rs." > + (let loop ((directory (getcwd))) > + (and (=3D (stat:uid (stat directory)) (getuid)) > + (or (any (lambda (candidate) > + (let ((candidate (string-append directory "/" candid= ate))) > + (and (file-exists? candidate) candidate))) > + candidates) > + (loop (string-append directory "/..")))))) ;Unix ".." resol= ution > + > +(define (auto-detect-manifest opts) > + "If OPTS do not specify packages or a manifest, load a \"guix.scm\" or > +\"manifest.scm\" file from the current directory or one of its ancestors= . > +Return the modified OPTS." > + (define (options-contain-payload? opts) > + (match opts > + (() #f) > + ((('package . _) . _) #t) > + ((('load . _) . _) #t) > + ((('manifest . _) . _) #t) > + ((('expression . _) . _) #t) > + ((_ . rest) (options-contain-payload? rest)))) > + > + (if (options-contain-payload? opts) > + opts > + (match (find-file-in-parent-directories '("guix.scm" "manifest.scm= ")) > + (#f > + (warning (G_ "no packages specified; creating an empty environm= ent~%")) > + opts) > + (file > + (info (G_ "loading environment from '~a'...~%") file) Could we have nice =E2=80=98curly quotes=E2=80=99 here: (info (G_ "loading environment from =E2=80=98~a=E2=80=99...~%") file) Greetings, Maxime. --=-HwFhDEgklzBYqVcJRbH8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYVwEBBccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7oKkAPwKaNzKVGx+AL+ncrNdaJSSur75 elAgSG/m8u9LFrNqsQEAuFU3chzE9XCEQIHbcx3qVuHyGj6PyQ2Cok7OqcsjYQA= =LxUM -----END PGP SIGNATURE----- --=-HwFhDEgklzBYqVcJRbH8--