diff options
author | nebuli <nebu@kipple> | 2014-11-30 17:47:22 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-11-30 18:54:07 +0100 |
commit | 16eb115ef4986f319e6aebb04cefce12bc851e01 (patch) | |
tree | d3f456766d9b90dd8f7e555a576457937e044918 /guix | |
parent | 6efc160efe6b91dd2ef2b74d551411d290c3b1f6 (diff) | |
download | gnu-guix-16eb115ef4986f319e6aebb04cefce12bc851e01.tar gnu-guix-16eb115ef4986f319e6aebb04cefce12bc851e01.tar.gz |
guix: scripts: Add GUIX_BUILD_OPTIONS environment handling.
* doc/guix.texi (Invoking guix build): Mention 'GUIX_BUILD_OPTIONS'.
* guix/scripts/archive.scm: (append args (environment-build-options)).
* guix/scripts/build.scm: Ditto.
* guix/scripts/environment.scm: Ditto.
* guix/scripts/package.scm: Ditto.
* guix/scripts/system.scm: Ditto.
* guix/ui.scm (environment-build-options): New function.
* guix/utils.scm (arguments-from-environment-variable): New function.
* tests/guix-build.sh: Add tests.
* test-env.in: Unset GUIX_BUILD_OPTIONS.
Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'guix')
-rw-r--r-- | guix/scripts/archive.scm | 3 | ||||
-rw-r--r-- | guix/scripts/build.scm | 3 | ||||
-rw-r--r-- | guix/scripts/environment.scm | 3 | ||||
-rw-r--r-- | guix/scripts/package.scm | 3 | ||||
-rw-r--r-- | guix/scripts/system.scm | 3 | ||||
-rw-r--r-- | guix/ui.scm | 5 | ||||
-rw-r--r-- | guix/utils.scm | 10 |
7 files changed, 25 insertions, 5 deletions
diff --git a/guix/scripts/archive.scm b/guix/scripts/archive.scm index 84904e29da..29a3ad15a7 100644 --- a/guix/scripts/archive.scm +++ b/guix/scripts/archive.scm @@ -293,7 +293,8 @@ the input port." (define (guix-archive . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options + (args-fold* (append args (environment-build-options)) + %options (lambda (opt name arg result) (leave (_ "~A: unrecognized option~%") name)) (lambda (arg result) diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index b4aa33b3a0..76a743f0b3 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -401,7 +401,8 @@ arguments with packages that use the specified source." (define (guix-build . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options + (args-fold* (append args (environment-build-options)) + %options (lambda (opt name arg result) (leave (_ "~A: unrecognized option~%") name)) (lambda (arg result) diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index 81bad963f6..a309dfa362 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -213,7 +213,8 @@ packages." ;; Entry point. (define (guix-environment . args) (define (parse-options) - (args-fold* args %options + (args-fold* (append args (environment-build-options)) + %options (lambda (opt name arg result) (leave (_ "~A: unrecognized option~%") name)) (lambda (arg result) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 3a72053766..9ff4d17bf4 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -668,7 +668,8 @@ removed from MANIFEST." (define (guix-package . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options + (args-fold* (append args (environment-build-options)) + %options (lambda (opt name arg result arg-handler) (leave (_ "~A: unrecognized option~%") name)) (lambda (arg result arg-handler) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 398a5a371b..8ea77e4f3c 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -467,7 +467,8 @@ Build the operating system declared in FILE according to ACTION.\n")) (define (guix-system . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options + (args-fold* (append args (environment-build-options)) + %options (lambda (opt name arg result) (leave (_ "~A: unrecognized option~%") name)) (lambda (arg result) diff --git a/guix/ui.scm b/guix/ui.scm index 69b073da50..c77e04172e 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -64,6 +64,7 @@ string->generations string->duration args-fold* + environment-build-options run-guix-command program-name guix-warning-port @@ -712,6 +713,10 @@ reporting." (leave (_ "invalid argument: ~a~%") (apply format #f msg args))))) +(define (environment-build-options) + "Return additional build options passed as environment variables." + (arguments-from-environment-variable "GUIX_BUILD_OPTIONS")) + (define (show-guix-usage) (format (current-error-port) (_ "Try `guix --help' for more information.~%")) diff --git a/guix/utils.scm b/guix/utils.scm index 9b802b6fb3..d0d2e8a3d4 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -72,6 +72,7 @@ package-name->name+version string-tokenize* string-replace-substring + arguments-from-environment-variable file-extension file-sans-extension call-with-temporary-output-file @@ -627,6 +628,15 @@ REPLACEMENT." (substring str start index) pieces)))))))) +(define (arguments-from-environment-variable variable) + "Retrieve value of environment variable denoted by string VARIABLE in the +form of a list of strings (`char-set:graphic' tokens) suitable for consumption +by `args-fold', if VARIABLE is defined, otherwise return an empty list." + (let ((env (getenv variable))) + (if env + (string-tokenize env char-set:graphic) + '()))) + (define (call-with-temporary-output-file proc) "Call PROC with a name of a temporary file and open output port to that file; close the file and delete it when leaving the dynamic extent of this |