diff options
author | Marius Bakke <marius@gnu.org> | 2021-06-19 17:38:47 +0200 |
---|---|---|
committer | Marius Bakke <marius@gnu.org> | 2021-06-19 17:38:47 +0200 |
commit | 6f9a80b331ae41d142a49fbeb94b90ee587b6155 (patch) | |
tree | 2da042a6ccf5368c73d6e3d54c2ee02a62d284e4 /guix/profiles.scm | |
parent | 6500c9a5b364616e38a7e03aa4516fc2d7cee876 (diff) | |
parent | dece03e2b98fc1c2428c2448ce5792f813eb79bf (diff) | |
download | guix-patches-6f9a80b331ae41d142a49fbeb94b90ee587b6155.tar guix-patches-6f9a80b331ae41d142a49fbeb94b90ee587b6155.tar.gz |
Merge branch 'master' into core-updates
Note: this merge actually changes the 'curl' and 'python-attrs' derivations,
as part of solving caf4a7a2770ef4d05a6e18f40d602e51da749ddc and
12964df69a99de6190422c752fef65ef813f3b6b respectively.
4604d43c0e (gnu: gnutls@3.6.16: Fix cross-compilation.) was ignored because it
cannot currently be tested.
Conflicts:
gnu/local.mk
gnu/packages/aidc.scm
gnu/packages/boost.scm
gnu/packages/curl.scm
gnu/packages/nettle.scm
gnu/packages/networking.scm
gnu/packages/python-xyz.scm
gnu/packages/tls.scm
Diffstat (limited to 'guix/profiles.scm')
-rw-r--r-- | guix/profiles.scm | 66 |
1 files changed, 48 insertions, 18 deletions
diff --git a/guix/profiles.scm b/guix/profiles.scm index 5f9a8a87a9..ebd671c82e 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -11,6 +11,7 @@ ;;; Copyright © 2019 Kyle Meyer <kyle@kyleam.com> ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org> +;;; Copyright © 2014 David Thompson <davet@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -54,6 +55,7 @@ #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) + #:autoload (srfi srfi-98) (get-environment-variables) #:export (&profile-error profile-error? profile-error-profile @@ -127,6 +129,7 @@ %default-profile-hooks profile-derivation profile-search-paths + load-profile profile profile? @@ -1713,12 +1716,10 @@ are cross-built for TARGET." (mapm/accumulate-builds (lambda (hook) (hook manifest)) hooks)))) - (define inputs - (append (filter-map (lambda (drv) - (and (derivation? drv) - (gexp-input drv))) - extras) - (manifest-inputs manifest))) + (define extra-inputs + (filter-map (lambda (drv) + (and (derivation? drv) (gexp-input drv))) + extras)) (define glibc-utf8-locales ;lazy reference (module-ref (resolve-interface '(gnu packages base)) @@ -1752,20 +1753,11 @@ are cross-built for TARGET." #+(if locales? set-utf8-locale #t) - (define search-paths - ;; Search paths of MANIFEST's packages, converted back to their - ;; record form. - (map sexp->search-path-specification - (delete-duplicates - '#$(map search-path-specification->sexp - (manifest-search-paths manifest))))) - - (build-profile #$output '#$inputs + (build-profile #$output '#$(manifest->gexp manifest) + #:extra-inputs '#$extra-inputs #:symlink #$(if relative-symlinks? #~symlink-relative - #~symlink) - #:manifest '#$(manifest->gexp manifest) - #:search-paths search-paths)))) + #~symlink))))) (gexp->derivation name builder #:system system @@ -1828,6 +1820,44 @@ already effective." (evaluate-search-paths (manifest-search-paths manifest) (list profile) getenv)) +(define %precious-variables + ;; Environment variables in the default 'load-profile' white list. + '("HOME" "USER" "LOGNAME" "DISPLAY" "XAUTHORITY" "TERM" "TZ" "PAGER")) + +(define (purify-environment white-list white-list-regexps) + "Unset all environment variables except those that match the regexps in +WHITE-LIST-REGEXPS and those listed in WHITE-LIST." + (for-each unsetenv + (remove (lambda (variable) + (or (member variable white-list) + (find (cut regexp-exec <> variable) + white-list-regexps))) + (match (get-environment-variables) + (((names . _) ...) + names))))) + +(define* (load-profile profile + #:optional (manifest (profile-manifest profile)) + #:key pure? (white-list-regexps '()) + (white-list %precious-variables)) + "Set the environment variables specified by MANIFEST for PROFILE. When +PURE? is #t, unset the variables in the current environment except those that +match the regexps in WHITE-LIST-REGEXPS and those listed in WHITE-LIST. +Otherwise, augment existing environment variables with additional search +paths." + (when pure? + (purify-environment white-list white-list-regexps)) + (for-each (match-lambda + ((($ <search-path-specification> variable _ separator) . value) + (let ((current (getenv variable))) + (setenv variable + (if (and current (not pure?)) + (if separator + (string-append value separator current) + value) + value))))) + (profile-search-paths profile manifest))) + (define (profile-regexp profile) "Return a regular expression that matches PROFILE's name and number." (make-regexp (string-append "^" (regexp-quote (basename profile)) |