From d664f1b431d2a64ff58ddc4ccce40e187947b960 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 6 May 2015 17:08:00 +0200 Subject: profiles: Generate an 'etc/profile' file. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suggested by 宋文武 in . * guix/build/profiles.scm (abstract-profile, write-environment-variable-definition): New procedures. (build-profile): Add #:search-paths parameter. Create OUTPUT/etc/profile. * guix/profiles.scm (profile-derivation)[builder]: Add 'search-paths' variable and pass it to 'build-profile'. Adjust #:modules argument. * tests/profiles.scm ("etc/profile"): New test. * doc/guix.texi (Invoking guix package): Mention etc/profile. --- tests/profiles.scm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/profiles.scm b/tests/profiles.scm index 890f09a751..a39717191d 100644 --- a/tests/profiles.scm +++ b/tests/profiles.scm @@ -29,6 +29,8 @@ #:use-module ((gnu packages guile) #:prefix packages:) #:use-module (ice-9 match) #:use-module (ice-9 regex) + #:use-module (ice-9 popen) + #:use-module (rnrs io ports) #:use-module (srfi srfi-11) #:use-module (srfi srfi-64)) @@ -220,6 +222,30 @@ (manifest-entry-search-paths entry) (package-native-search-paths packages:guile-2.0))))))))) + +(test-assertm "etc/profile" + ;; Make sure we get an 'etc/profile' file that at least defines $PATH. + (mlet* %store-monad + ((guile -> (package + (inherit %bootstrap-guile) + (native-search-paths + (package-native-search-paths packages:guile-2.0)))) + (entry -> (package->manifest-entry guile)) + (drv (profile-derivation (manifest (list entry)) + #:hooks '())) + (profile -> (derivation->output-path drv))) + (mbegin %store-monad + (built-derivations (list drv)) + (let* ((pipe (open-input-pipe + (string-append "source " + profile "/etc/profile; " + "unset GUIX_PROFILE; set"))) + (env (get-string-all pipe))) + (return + (and (zero? (close-pipe pipe)) + (string-contains env + (string-append "PATH=" profile "/bin")))))))) + (test-end "profiles") -- cgit v1.2.3