From patchwork Thu Feb 4 10:13:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lars-Dominik Braun X-Patchwork-Id: 26883 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 842E327BC2E; Thu, 4 Feb 2021 10:14:25 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 5020127BC1F for ; Thu, 4 Feb 2021 10:14:24 +0000 (GMT) Received: from localhost ([::1]:53270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7beZ-0004BU-AW for patchwork@mira.cbaines.net; Thu, 04 Feb 2021 05:14:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7beF-0004AR-8b for guix-patches@gnu.org; Thu, 04 Feb 2021 05:14:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:56463) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7beE-0006tC-6C for guix-patches@gnu.org; Thu, 04 Feb 2021 05:14:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l7beE-0006IH-0p for guix-patches@gnu.org; Thu, 04 Feb 2021 05:14:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#46291] [PATCH] environment: Allow starting from existing profile Resent-From: Lars-Dominik Braun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 04 Feb 2021 10:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46291 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 46291@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.161243362624159 (code B ref -1); Thu, 04 Feb 2021 10:14:01 +0000 Received: (at submit) by debbugs.gnu.org; 4 Feb 2021 10:13:46 +0000 Received: from localhost ([127.0.0.1]:39776 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7bdy-0006HZ-0P for submit@debbugs.gnu.org; Thu, 04 Feb 2021 05:13:46 -0500 Received: from lists.gnu.org ([209.51.188.17]:47102) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7bdw-0006HR-4t for submit@debbugs.gnu.org; Thu, 04 Feb 2021 05:13:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7bds-000411-3w for guix-patches@gnu.org; Thu, 04 Feb 2021 05:13:42 -0500 Received: from mout-p-102.mailbox.org ([2001:67c:2050::465:102]:57598) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1l7bdn-0006f2-HT for guix-patches@gnu.org; Thu, 04 Feb 2021 05:13:39 -0500 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4DWZBX5KkHzQlZq for ; Thu, 4 Feb 2021 11:13:24 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6xq.net; s=MBO0001; t=1612433602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NLd5OvZwHM8iokglGYCQfdrtEr8w2Ztr2rrsMIwAo6U=; b=C1l4bF+Qr9sNIUI6VzwWN7RVi903gb5DBapxEhP8nPiELzIb+4lyFGrfbr2jh96nc2p5bk CMm0YVO1J1UC34ht5UboX4+XhOic58xa/SCaAtlpryJb8MMHU/QmRRTVLTJyiuuhTuaoPx 2Zx5yzgKXBzfJLqKFwfauHjI/TWIp/VoMP8mPsjxBo5AegqGRi3Bhmh3TS892GsMkWKGYx a/vwh20aBXtWYOqtO0aA8K0HdRfYE5zdLTUWaGAk/gwkDtSm2Z6/EYN5yLl5OJ3OEnLjLQ kMCns1fh4eVnNOf+N846HQQ6AP5FXWW8Hwaeb1Ofn2UTlGGQFcB90JNBiLv7Ug== Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id k-V0xkOgPSXu for ; Thu, 4 Feb 2021 11:13:21 +0100 (CET) Date: Thu, 4 Feb 2021 11:13:20 +0100 From: Lars-Dominik Braun Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-MBO-SPAM-Probability: X-Rspamd-Score: -6.49 / 15.00 / 15.00 X-Rspamd-Queue-Id: C7C2D17F5 X-Rspamd-UID: 3dd4ce Received-SPF: pass client-ip=2001:67c:2050::465:102; envelope-from=lars@6xq.net; helo=mout-p-102.mailbox.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi everyone, the attched patch allows starting a `guix environment` from an existing profile. Our use-case is this: We have profiles, created by guix package -p /path -i … because we need to parse desktop files in /path/share/applications. Also this does the heavy-lifting (substitutes/building/grafting) upfront once and not when starting an environment. Then we start an application from this profile using guix environment -C […] -p /path -- jupyterlab […] This is much faster (10x) for large profiles (i.e. JupyterLab) than guix environment -C […] -m manifest.scm -- jupyterlab […] and makes sure the environment is exactly the same as source /path/etc/profile I think there have been many discussions about how `guix environment` should work and this is certainly not the silver bullet, but it’s a huge improvement for us with very limited code changes required. Cheers, Lars From 3010cea7273f02e33f65dd5d78390f0f5b7e4698 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Thu, 4 Feb 2021 10:43:45 +0100 Subject: [PATCH] environment: Allow starting from existing profile * guix/scripts/environment.scm (%options): Add -p/--profile switch. (show-help): Document new switch. (guix-environment): Handle new 'profile switch. --- guix/scripts/environment.scm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index f4d12f89bf..25bc208489 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -21,6 +21,7 @@ (define-module (guix scripts environment) #:use-module (guix ui) #:use-module (guix store) + #:use-module (guix utils) #:use-module ((guix status) #:select (with-status-verbosity)) #:use-module (guix grafts) #:use-module (guix derivations) @@ -136,6 +137,8 @@ COMMAND or an interactive shell in that environment.\n")) FILE evaluates to")) (display (G_ " -m, --manifest=FILE create environment with the manifest from FILE")) + (display (G_ " + -p, --profile=PATH create environment from profile at PATH")) (display (G_ " --ad-hoc include all specified packages in the environment instead of only their inputs")) @@ -269,6 +272,10 @@ use '--preserve' instead~%")) (option '(#\P "link-profile") #f #f (lambda (opt name arg result) (alist-cons 'link-profile? #t result))) + (option '(#\p "profile") #t #f + (lambda (opt name arg result) + (alist-cons 'profile arg + (alist-delete 'profile result eq?)))) (option '(#\u "user") #t #f (lambda (opt name arg result) (alist-cons 'user arg @@ -706,6 +713,7 @@ message if any test fails." (user (assoc-ref opts 'user)) (bootstrap? (assoc-ref opts 'bootstrap?)) (system (assoc-ref opts 'system)) + (profile (assoc-ref opts 'profile)) (command (or (assoc-ref opts 'exec) ;; Spawn a shell if the user didn't specify ;; anything in particular. @@ -735,8 +743,15 @@ message if any test fails." #:dry-run? (assoc-ref opts 'dry-run?)) (with-status-verbosity (assoc-ref opts 'verbosity) - (define manifest + (define manifest-from-opts (options/resolve-packages store opts)) + (when (and profile (> (length (manifest-entries manifest-from-opts)) 0)) + (leave (G_ "'--profile' cannot be used with package options~%"))) + + (define manifest + (if profile + (profile-manifest profile) + manifest-from-opts)) (set-build-options-from-command-line store opts) @@ -755,7 +770,9 @@ message if any test fails." system)) (prof-drv (manifest->derivation manifest system bootstrap?)) - (profile -> (derivation->output-path prof-drv)) + (profile -> (if profile + (readlink* profile) + (derivation->output-path prof-drv))) (gc-root -> (assoc-ref opts 'gc-root))) ;; First build the inputs. This is necessary even for -- 2.26.2