From unknown Fri Aug 15 04:04:24 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#32104 <32104@debbugs.gnu.org> To: bug#32104 <32104@debbugs.gnu.org> Subject: Status: [PATCH 0/3] guix environment: Simplify environment creation Reply-To: bug#32104 <32104@debbugs.gnu.org> Date: Fri, 15 Aug 2025 11:04:24 +0000 retitle 32104 [PATCH 0/3] guix environment: Simplify environment creation reassign 32104 guix-patches submitter 32104 Ludovic Court=C3=A8s severity 32104 normal tag 32104 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 09 07:32:13 2018 Received: (at submit) by debbugs.gnu.org; 9 Jul 2018 11:32:13 +0000 Received: from localhost ([127.0.0.1]:51761 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fcUOq-0001SA-Ql for submit@debbugs.gnu.org; Mon, 09 Jul 2018 07:32:12 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46830) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fcUOq-0001Ry-2D for submit@debbugs.gnu.org; Mon, 09 Jul 2018 07:32:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcUOk-0002fZ-4O for submit@debbugs.gnu.org; Mon, 09 Jul 2018 07:32:06 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:50745) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fcUOk-0002fV-1g for submit@debbugs.gnu.org; Mon, 09 Jul 2018 07:32:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcUOj-0004LV-31 for guix-patches@gnu.org; Mon, 09 Jul 2018 07:32:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcUOi-0002f6-9x for guix-patches@gnu.org; Mon, 09 Jul 2018 07:32:05 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52730) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcUOd-0002dx-RR; Mon, 09 Jul 2018 07:31:59 -0400 Received: from [193.50.110.150] (port=58198 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fcUOc-0005kN-Vn; Mon, 09 Jul 2018 07:31:59 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-patches@gnu.org Subject: [PATCH 0/3] guix environment: Simplify environment creation Date: Mon, 9 Jul 2018 13:31:47 +0200 Message-Id: <20180709113147.15020-1-ludo@gnu.org> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) Hello Guix! These patches aim to simplify (guix scripts environment) by (1) factorizing part of the search path handling machinery in (guix profiles), and (2) by using manifests internally instead of loosely defined lists of “inputs.” The goal is to gradually move towards a situation where (guix scripts environment) contains nothing but UI code and related plumbing. Ludo’. Ludovic Courtès (3): profiles: Factorize 'manifest-search-paths'. environment: Simplify code by using manifests internally. profiles: Introduce 'profile-search-paths' and use it. guix/build/profiles.scm | 2 +- guix/profiles.scm | 26 ++++- guix/scripts/environment.scm | 208 ++++++++++++++--------------------- 3 files changed, 110 insertions(+), 126 deletions(-) -- 2.18.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 09 07:40:19 2018 Received: (at 32104) by debbugs.gnu.org; 9 Jul 2018 11:40:19 +0000 Received: from localhost ([127.0.0.1]:51778 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fcUWg-0001e6-Jy for submit@debbugs.gnu.org; Mon, 09 Jul 2018 07:40:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50282) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fcUWe-0001ds-LE for 32104@debbugs.gnu.org; Mon, 09 Jul 2018 07:40:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcUWY-0007t5-Kn for 32104@debbugs.gnu.org; Mon, 09 Jul 2018 07:40:11 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52838) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcUWU-0007re-7N; Mon, 09 Jul 2018 07:40:06 -0400 Received: from [193.50.110.150] (port=58208 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fcUWS-0007g8-OG; Mon, 09 Jul 2018 07:40:05 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 32104@debbugs.gnu.org Subject: [PATCH 1/3] profiles: Factorize 'manifest-search-paths'. Date: Mon, 9 Jul 2018 13:39:52 +0200 Message-Id: <20180709113954.15272-1-ludo@gnu.org> X-Mailer: git-send-email 2.18.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 32104 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) * guix/profiles.scm (manifest-search-paths): New procedure. (profile-derivation)[builder]: Use it. * guix/build/profiles.scm (build-etc/profile): Remove $PATH. --- guix/build/profiles.scm | 2 +- guix/profiles.scm | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/guix/build/profiles.scm b/guix/build/profiles.scm index 819688a91..df785c85a 100644 --- a/guix/build/profiles.scm +++ b/guix/build/profiles.scm @@ -89,7 +89,7 @@ definitions for all the SEARCH-PATHS." # When GUIX_PROFILE is undefined, the various environment variables refer # to this specific profile generation. \n" port) - (let ((variables (evaluate-search-paths (cons $PATH search-paths) + (let ((variables (evaluate-search-paths search-paths (list output)))) (for-each (write-environment-variable-definition port) (map (abstract-profile output) variables)))))) diff --git a/guix/profiles.scm b/guix/profiles.scm index e6b77e8d3..88228f155 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -91,6 +91,7 @@ manifest-lookup manifest-installed? manifest-matching-entries + manifest-search-paths manifest-transaction manifest-transaction? @@ -545,6 +546,14 @@ no match.." (filter matches? (manifest-entries manifest))) +(define (manifest-search-paths manifest) + "Return the list of search path specifications that apply to MANIFEST, +including the search path specification for $PATH." + (delete-duplicates + (cons $PATH + (append-map manifest-entry-search-paths + (manifest-entries manifest))))) + ;;; ;;; Manifest transactions. @@ -1367,8 +1376,7 @@ are cross-built for TARGET." (map sexp->search-path-specification (delete-duplicates '#$(map search-path-specification->sexp - (append-map manifest-entry-search-paths - (manifest-entries manifest)))))) + (manifest-search-paths manifest))))) (build-profile #$output '#$inputs #:symlink #$(if relative-symlinks? -- 2.18.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 09 07:40:22 2018 Received: (at 32104) by debbugs.gnu.org; 9 Jul 2018 11:40:22 +0000 Received: from localhost ([127.0.0.1]:51782 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fcUWi-0001eP-BN for submit@debbugs.gnu.org; Mon, 09 Jul 2018 07:40:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50290) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fcUWf-0001dt-D7 for 32104@debbugs.gnu.org; Mon, 09 Jul 2018 07:40:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcUWY-0007tA-PI for 32104@debbugs.gnu.org; Mon, 09 Jul 2018 07:40:12 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcUWV-0007s1-RS; Mon, 09 Jul 2018 07:40:07 -0400 Received: from [193.50.110.150] (port=58208 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fcUWU-0007g8-Fl; Mon, 09 Jul 2018 07:40:07 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 32104@debbugs.gnu.org Subject: [PATCH 2/3] environment: Simplify code by using manifests internally. Date: Mon, 9 Jul 2018 13:39:53 +0200 Message-Id: <20180709113954.15272-2-ludo@gnu.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180709113954.15272-1-ludo@gnu.org> References: <20180709113954.15272-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 32104 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) * guix/scripts/environment.scm (strip-input-name) (package+propagated-inputs, package-or-package+output?) (compact): Remove. (inputs->profile-derivation): Rename to... (manifest->derivation): ... this. Replace 'inputs' parameter with 'manifest'. (input->manifest-entry): New procedure. (package-environment-inputs): Rewrite to return a list of manifest entries. (options/resolve-packages): Rewrite to return a manifest. (guix-environment): Remove 'inputs'. Define 'paths' in terms of 'manifest-search-paths'. --- guix/scripts/environment.scm | 156 ++++++++++++++--------------------- 1 file changed, 61 insertions(+), 95 deletions(-) diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index f8a9702b3..9a69e3b26 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014, 2015, 2018 David Thompson -;;; Copyright © 2015, 2016, 2017 Ludovic Courtès +;;; Copyright © 2015, 2016, 2017, 2018 Ludovic Courtès ;;; Copyright © 2018 Mike Gerwitz ;;; ;;; This file is part of GNU Guix. @@ -102,35 +102,23 @@ existing environment variables with additional search paths." (newline))) (evaluate-profile-search-paths profile search-paths))) -(define (strip-input-name input) - "Remove the name element from the tuple INPUT." +(define (input->manifest-entry input) + "Return a manifest entry for INPUT, or #f if INPUT does not correspond to a +package." (match input - ((_ package) package) - ((_ package output) - (list package output)))) - -(define (package+propagated-inputs package output) - "Return the union of PACKAGE's OUTPUT and its transitive propagated inputs." - (cons (list package output) - (map strip-input-name - (package-transitive-propagated-inputs package)))) - -(define (package-or-package+output? expr) - "Return #t if EXPR is a package or a 2 element list consisting of a package -and an output string." - (match expr - ((or (? package?) ; bare package object - ((? package?) (? string?))) ; package+output tuple - #t) - (_ #f))) + ((_ (? package? package)) + (package->manifest-entry package)) + ((_ (? package? package) output) + (package->manifest-entry package output)) + (_ + #f))) (define (package-environment-inputs package) - "Return a list of the transitive input packages for PACKAGE." + "Return a list of manifest entries corresponding to the transitive input +packages for PACKAGE." ;; Remove non-package inputs such as origin records. - (filter package-or-package+output? - (map strip-input-name - (bag-transitive-inputs - (package->bag package))))) + (filter-map input->manifest-entry + (bag-transitive-inputs (package->bag package)))) (define (show-help) (display (G_ "Usage: guix environment [OPTION]... PACKAGE... [-- COMMAND...] @@ -287,55 +275,50 @@ COMMAND or an interactive shell in that environment.\n")) (_ memo))) '() alist)) -(define (compact lst) - "Remove all #f elements from LST." - (filter identity lst)) - (define (options/resolve-packages opts) - "Return OPTS with package specification strings replaced by actual -packages." - (define (package->output package mode) - (match package - ((? package?) - (list mode package "out")) - (((? package? package) (? string? output)) - (list mode package output)))) + "Return OPTS with package specification strings replaced by manifest entries +for the corresponding packages." + (define (manifest-entry=? e1 e2) + (and (eq? (manifest-entry-item e1) (manifest-entry-item e2)) + (string=? (manifest-entry-output e1) + (manifest-entry-output e2)))) (define (packages->outputs packages mode) (match packages - ((? package-or-package+output? package) ; single package - (list (package->output package mode))) - (((? package-or-package+output?) ...) ; many packages - (map (cut package->output <> mode) packages)))) + ((? package? package) + (if (eq? mode 'ad-hoc-package) + (list (package->manifest-entry package)) + (package-environment-inputs package))) + (((? package? package) (? string? output)) + (if (eq? mode 'ad-hoc-package) + (list (package->manifest-entry package output)) + (package-environment-inputs package))) + ((lst ...) + (append-map (cut packages->outputs <> mode) lst)))) - (define (manifest->outputs manifest) - (map (lambda (entry) - (cons 'ad-hoc-package ; manifests are implicitly ad-hoc - (if (package? (manifest-entry-item entry)) - (list (manifest-entry-item entry) - (manifest-entry-output entry)) - ;; Direct store paths have no output. - (list (manifest-entry-item entry))))) - (manifest-entries manifest))) - - (compact - (append-map (match-lambda - (('package mode (? string? spec)) - (let-values (((package output) - (specification->package+output spec))) - (list (list mode package output)))) - (('expression mode str) - ;; Add all the outputs of the package STR evaluates to. - (packages->outputs (read/eval str) mode)) - (('load mode file) - ;; Add all the outputs of the package defined in FILE. - (let ((module (make-user-module '()))) - (packages->outputs (load* file module) mode))) - (('manifest . file) - (let ((module (make-user-module '((guix profiles) (gnu))))) - (manifest->outputs (load* file module)))) - (_ '(#f))) - opts))) + (manifest + (delete-duplicates + (append-map (match-lambda + (('package 'ad-hoc-package (? string? spec)) + (let-values (((package output) + (specification->package+output spec))) + (list (package->manifest-entry package output)))) + (('package 'package (? string? spec)) + (package-environment-inputs + (specification->package+output spec))) + (('expression mode str) + ;; Add all the outputs of the package STR evaluates to. + (packages->outputs (read/eval str) mode)) + (('load mode file) + ;; Add all the outputs of the package defined in FILE. + (let ((module (make-user-module '()))) + (packages->outputs (load* file module) mode))) + (('manifest . file) + (let ((module (make-user-module '((guix profiles) (gnu))))) + (manifest-entries (load* file module)))) + (_ '())) + opts) + manifest-entry=?))) (define* (build-environment derivations opts) "Build the DERIVATIONS required by the environment using the build options @@ -350,11 +333,10 @@ in OPTS." (return #f) (built-derivations derivations))))) -(define (inputs->profile-derivation inputs system bootstrap?) - "Return the derivation for a profile consisting of INPUTS for SYSTEM. -BOOTSTRAP? specifies whether to use the bootstrap Guile to build the -profile." - (profile-derivation (packages->manifest inputs) +(define (manifest->derivation manifest system bootstrap?) + "Return the derivation for a profile of MANIFEST. +BOOTSTRAP? specifies whether to use the bootstrap Guile to build the profile." + (profile-derivation manifest #:system system ;; Packages can have conflicting inputs, or explicit @@ -671,25 +653,9 @@ message if any test fails." ;; within the container. '("/bin/sh") (list %default-shell)))) - (packages (options/resolve-packages opts)) + (manifest (options/resolve-packages opts)) (mappings (pick-all opts 'file-system-mapping)) - (inputs (delete-duplicates - (append-map (match-lambda - (('ad-hoc-package package output) - (package+propagated-inputs package - output)) - (('package package _) - (package-environment-inputs package))) - packages))) - (paths (delete-duplicates - (cons $PATH - (append-map (match-lambda - ((or ((? package? p) _ ...) - (? package? p)) - (package-native-search-paths p)) - (_ '())) - inputs)) - eq?))) + (paths (manifest-search-paths manifest))) (when container? (assert-container-features)) @@ -714,8 +680,8 @@ message if any test fails." (mlet* %store-monad ((bash (environment-bash container? bootstrap? system)) - (prof-drv (inputs->profile-derivation - inputs system bootstrap?)) + (prof-drv (manifest->derivation + manifest system bootstrap?)) (profile -> (derivation->output-path prof-drv)) (gc-root -> (assoc-ref opts 'gc-root))) -- 2.18.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 09 07:40:23 2018 Received: (at 32104) by debbugs.gnu.org; 9 Jul 2018 11:40:23 +0000 Received: from localhost ([127.0.0.1]:51784 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fcUWk-0001eV-N4 for submit@debbugs.gnu.org; Mon, 09 Jul 2018 07:40:23 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50313) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fcUWh-0001dw-BA for 32104@debbugs.gnu.org; Mon, 09 Jul 2018 07:40:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcUWa-0007ti-89 for 32104@debbugs.gnu.org; Mon, 09 Jul 2018 07:40:14 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcUWX-0007sh-HJ; Mon, 09 Jul 2018 07:40:09 -0400 Received: from [193.50.110.150] (port=58208 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fcUWW-0007g8-5v; Mon, 09 Jul 2018 07:40:08 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 32104@debbugs.gnu.org Subject: [PATCH 3/3] profiles: Introduce 'profile-search-paths' and use it. Date: Mon, 9 Jul 2018 13:39:54 +0200 Message-Id: <20180709113954.15272-3-ludo@gnu.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180709113954.15272-1-ludo@gnu.org> References: <20180709113954.15272-1-ludo@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 32104 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) * guix/profiles.scm (profile-search-paths): New procedure. * guix/scripts/environment.scm (evaluate-search-paths): Remove. (create-environment): Replace 'paths' with 'manifest'. Use 'profile-search-paths' instead of 'evaluate-search-paths'. (show-search-paths): Likewise. (launch-environment): Replace 'paths' with 'manifest'. Make 'pure?' a keyword parameter. (launch-environment/fork, launch-environment/container): Likewise. (guix-environment): Remove 'paths' variable. Adjust callers of the above procedures accordingly. --- guix/profiles.scm | 14 ++++++++++ guix/scripts/environment.scm | 54 +++++++++++++++++------------------- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/guix/profiles.scm b/guix/profiles.scm index 88228f155..d2a794b18 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -110,6 +110,7 @@ ca-certificate-bundle %default-profile-hooks profile-derivation + profile-search-paths generation-number generation-numbers @@ -1400,6 +1401,19 @@ are cross-built for TARGET." ;; to have no substitute to offer. #:substitutable? #f))) +(define* (profile-search-paths profile + #:optional (manifest (profile-manifest profile)) + #:key (getenv (const #f))) + "Read the manifest of PROFILE and evaluate the values of search path +environment variables required by PROFILE; return a list of +specification/value pairs. If MANIFEST is not #f, it is assumed to be the +manifest of PROFILE, which avoids rereading it. + +Use GETENV to determine the current settings and report only settings not +already effective." + (evaluate-search-paths (manifest-search-paths manifest) + (list profile) getenv)) + (define (profile-regexp profile) "Return a regular expression that matches PROFILE's name and number." (make-regexp (string-append "^" (regexp-quote (basename profile)) diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index 9a69e3b26..1c04800e4 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -49,11 +49,6 @@ #:use-module (srfi srfi-98) #:export (guix-environment)) -(define (evaluate-profile-search-paths profile search-paths) - "Evaluate SEARCH-PATHS, a list of search-path specifications, for the -directories in PROFILE, the store path of a profile." - (evaluate-search-paths search-paths (list profile))) - ;; Protect some env vars from purification. Borrowed from nix-shell. (define %precious-variables '("HOME" "USER" "LOGNAME" "DISPLAY" "TERM" "TZ" "PAGER")) @@ -70,8 +65,8 @@ as 'HOME' and 'USER' are left untouched." (((names . _) ...) names))))) -(define (create-environment profile paths pure?) - "Set the environment variables specified by PATHS for PROFILE. When PURE? +(define* (create-environment profile manifest #:key pure?) + "Set the environment variables specified by MANIFEST for PROFILE. When PURE? is #t, unset the variables in the current environment. Otherwise, augment existing environment variables with additional search paths." (when pure? (purify-environment)) @@ -84,23 +79,23 @@ existing environment variables with additional search paths." (string-append value separator current) value) value))))) - (evaluate-profile-search-paths profile paths)) + (profile-search-paths profile manifest)) ;; Give users a way to know that they're in 'guix environment', so they can ;; adjust 'PS1' accordingly, for instance. Set it to PROFILE so users can ;; conveniently access its contents. (setenv "GUIX_ENVIRONMENT" profile)) -(define (show-search-paths profile search-paths pure?) - "Display SEARCH-PATHS applied to PROFILE. When PURE? is #t, do not augment -existing environment variables with additional search paths." +(define* (show-search-paths profile manifest #:key pure?) + "Display the search paths of MANIFEST applied to PROFILE. When PURE? is #t, +do not augment existing environment variables with additional search paths." (for-each (match-lambda ((search-path . value) (display (search-path-definition search-path value #:kind (if pure? 'exact 'prefix))) (newline))) - (evaluate-profile-search-paths profile search-paths))) + (profile-search-paths profile manifest))) (define (input->manifest-entry input) "Return a manifest entry for INPUT, or #f if INPUT does not correspond to a @@ -379,32 +374,34 @@ and suitable for 'exit'." (define exit/status (compose exit status->exit-code)) (define primitive-exit/status (compose primitive-exit status->exit-code)) -(define (launch-environment command inputs paths pure?) +(define* (launch-environment command profile manifest + #:key pure?) "Run COMMAND in a new environment containing INPUTS, using the native search paths defined by the list PATHS. When PURE?, pre-existing environment variables are cleared before setting the new ones." ;; Properly handle SIGINT, so pressing C-c in an interactive terminal ;; application works. (sigaction SIGINT SIG_DFL) - (create-environment inputs paths pure?) + (create-environment profile manifest #:pure? pure?) (match command ((program . args) (apply execlp program program args)))) -(define (launch-environment/fork command inputs paths pure?) - "Run COMMAND in a new process with an environment containing INPUTS, using -the native search paths defined by the list PATHS. When PURE?, pre-existing -environment variables are cleared before setting the new ones." +(define* (launch-environment/fork command profile manifest #:key pure?) + "Run COMMAND in a new process with an environment containing PROFILE, with +the search paths specified by MANIFEST. When PURE?, pre-existing environment +variables are cleared before setting the new ones." (match (primitive-fork) - (0 (launch-environment command inputs paths pure?)) + (0 (launch-environment command profile manifest + #:pure? pure?)) (pid (match (waitpid pid) ((_ . status) status))))) (define* (launch-environment/container #:key command bash user user-mappings - profile paths link-profile? network?) + profile manifest link-profile? network?) "Run COMMAND within a container that features the software in PROFILE. -Environment variables are set according to PATHS, a list of native search -paths. The global shell is BASH, a file name for a GNU Bash binary in the +Environment variables are set according to the search paths of MANIFEST. +The global shell is BASH, a file name for a GNU Bash binary in the store. When NETWORK?, access to the host system network is permitted. USER-MAPPINGS, a list of file system mappings, contains the user-specified host file systems to mount inside the container. If USER is not #f, each @@ -496,7 +493,7 @@ will be used for the passwd entry. LINK-PROFILE? creates a symbolic link from (primitive-exit/status ;; A container's environment is already purified, so no need to ;; request it be purified again. - (launch-environment command profile paths #f))) + (launch-environment command profile manifest #:pure? #f))) #:namespaces (if network? (delq 'net %namespaces) ; share host network %namespaces))))))) @@ -654,8 +651,7 @@ message if any test fails." '("/bin/sh") (list %default-shell)))) (manifest (options/resolve-packages opts)) - (mappings (pick-all opts 'file-system-mapping)) - (paths (manifest-search-paths manifest))) + (mappings (pick-all opts 'file-system-mapping))) (when container? (assert-container-features)) @@ -700,7 +696,7 @@ message if any test fails." ((assoc-ref opts 'dry-run?) (return #t)) ((assoc-ref opts 'search-paths) - (show-search-paths profile paths pure?) + (show-search-paths profile manifest #:pure? pure?) (return #t)) (container? (let ((bash-binary @@ -713,11 +709,11 @@ message if any test fails." #:user user #:user-mappings mappings #:profile profile - #:paths paths + #:manifest manifest #:link-profile? link-prof? #:network? network?))) (else (return (exit/status - (launch-environment/fork command profile - paths pure?))))))))))))) + (launch-environment/fork command profile manifest + #:pure? pure?))))))))))))) -- 2.18.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 09 09:22:49 2018 Received: (at 32104) by debbugs.gnu.org; 9 Jul 2018 13:22:49 +0000 Received: from localhost ([127.0.0.1]:51831 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fcW7s-0003yb-Sc for submit@debbugs.gnu.org; Mon, 09 Jul 2018 09:22:49 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33210) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fcW7r-0003yP-SY for 32104@debbugs.gnu.org; Mon, 09 Jul 2018 09:22:48 -0400 Received: by mail-wm0-f68.google.com with SMTP id z6-v6so10964781wma.0 for <32104@debbugs.gnu.org>; Mon, 09 Jul 2018 06:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=worcester-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Wb/yriWjeZJZ361bEfxGapl8Lgf+jOb520SWVzGrvVk=; b=kcYK3FCydP9mibDo3iAwI2lEYp3IYVYuMGW/uZzW4cOs0Phk0W/ffXkNK5AjkbL5iF DWJEGkfknlNwe0uSKWeub0mDNxAYgTvutSrQk3oWqFBcdYqiWriG6iMygO78AmspSUr1 5N9sEkDfzMalU8HjWtPLv97jmHJB3yfuG9INxK0P+TGDu6iL85chanFeaFxixM1fquNJ EVKe286D9wgx//RPB+Xl00r9/w1pZ4L0snZPz3wF8AAgrKpzk4DzM/OIj9h6vN6dhNWM Igm8mNq1SO6ARMN/jhbgKXkM6l/WSmazbSs575cGQGPgsn+102P1/3twqCJLF7uSAKIs D1LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Wb/yriWjeZJZ361bEfxGapl8Lgf+jOb520SWVzGrvVk=; b=GzH5tleBt4JFj9un5m0AmdF/XpwhsNfhraX07Lge8Abu6zTW2Z5bF9cwCNZoMhoZx1 gsorCVTvRFa3ivNPp1Dz4oanvxRhGob3+rw/cnrLW7ONtWOApAdF349QpOrBAQnDz7C7 hkny8bQpgzCgF9GYRqxZ8JfkKy4EqDNY6t1YatqRSzFLevKfyvr+Pl7byZ7nPRbRWYSN EKPu/Vu9+Mc5enSJ/MPS/pO+cKmk0W43UDAzDoWLdiosicY2Du0qsoE3Bfl4mwS+835J RSBF2GnWYzewAdDgmyvLJzOBDCbTmasbkhMH4m88ixVs6u7JlGUho/15g+V0NPB3Y9f9 mKng== X-Gm-Message-State: APt69E1JxR3P6+y5c3CfiUlNxlgJoamMZfLblhW7M3jBgp+UofYUlg3H xl1pVf9XY/yLPHJ9znLWC2cFgvYmmQrA/dDbZOebVQ== X-Google-Smtp-Source: AAOMgpeutMPdFGQNymQx+QT3i82N3en7wOLiPMXRQkFPsonai+UIvJa0bwFXbx1FetJZYgtsMdK0jssB/Orn9O7p/E8= X-Received: by 2002:a1c:9f12:: with SMTP id i18-v6mr12173997wme.124.1531142562143; Mon, 09 Jul 2018 06:22:42 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a5d:4207:0:0:0:0:0 with HTTP; Mon, 9 Jul 2018 06:22:41 -0700 (PDT) In-Reply-To: <20180709113147.15020-1-ludo@gnu.org> References: <20180709113147.15020-1-ludo@gnu.org> From: "Thompson, David" Date: Mon, 9 Jul 2018 09:22:41 -0400 Message-ID: Subject: Re: [bug#32104] [PATCH 0/3] guix environment: Simplify environment creation To: =?UTF-8?Q?Ludovic_Court=C3=A8s?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 32104 Cc: 32104@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hey Ludo, On Mon, Jul 9, 2018 at 7:31 AM, Ludovic Court=C3=A8s wrote: > Hello Guix! > > These patches aim to simplify (guix scripts environment) by (1) factorizi= ng > part of the search path handling machinery in (guix profiles), and (2) by > using manifests internally instead of loosely defined lists of =E2=80=9Ci= nputs.=E2=80=9D > > The goal is to gradually move towards a situation where (guix scripts > environment) contains nothing but UI code and related plumbing. This is a great initiative. Using manifests for everything makes a lot of sense. All the patches look good to me! - Dave From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 10 19:02:38 2018 Received: (at 32104-done) by debbugs.gnu.org; 10 Jul 2018 23:02:38 +0000 Received: from localhost ([127.0.0.1]:54439 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fd1eY-0006H5-MQ for submit@debbugs.gnu.org; Tue, 10 Jul 2018 19:02:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55405) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fd1eW-0006Gs-8c for 32104-done@debbugs.gnu.org; Tue, 10 Jul 2018 19:02:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fd1eQ-0002Ey-E6 for 32104-done@debbugs.gnu.org; Tue, 10 Jul 2018 19:02:31 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:40830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fd1eQ-0002Eu-AG; Tue, 10 Jul 2018 19:02:30 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=44906 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fd1eP-0007Xw-Tl; Tue, 10 Jul 2018 19:02:30 -0400 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: "Thompson\, David" Subject: Re: [bug#32104] [PATCH 0/3] guix environment: Simplify environment creation References: <20180709113147.15020-1-ludo@gnu.org> Date: Wed, 11 Jul 2018 01:02:28 +0200 In-Reply-To: (David Thompson's message of "Mon, 9 Jul 2018 09:22:41 -0400") Message-ID: <87va9mofsr.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 32104-done Cc: 32104-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) Hey David, "Thompson, David" skribis: > On Mon, Jul 9, 2018 at 7:31 AM, Ludovic Court=C3=A8s wrote: >> Hello Guix! >> >> These patches aim to simplify (guix scripts environment) by (1) factoriz= ing >> part of the search path handling machinery in (guix profiles), and (2) by >> using manifests internally instead of loosely defined lists of =E2=80=9C= inputs.=E2=80=9D >> >> The goal is to gradually move towards a situation where (guix scripts >> environment) contains nothing but UI code and related plumbing. > > This is a great initiative. Using manifests for everything makes a lot > of sense. All the patches look good to me! Pushed now, thanks for reviewing! Ludo=E2=80=99. From unknown Fri Aug 15 04:04:24 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 08 Aug 2018 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator