unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Deck Pickard <deck.r.pickard@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH] Core sanity and taking build options from environment.
Date: Fri, 28 Nov 2014 00:13:52 +0100	[thread overview]
Message-ID: <CAJ41eezNiGrwADtd_+fS76m2rQivqwuTz2B2if1RYLt+YLRdtg@mail.gmail.com> (raw)
In-Reply-To: <CAJ41eezW0KRVu6TBE0UeUVnNgqFSxgwML5p+FDd5h_bH3N_ghg@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 417 bytes --]

  Perhaps GUIX_BUILD (suffix with _OPTS or some such?) is not the best name
and I'm not certain if it shouldn't be stdout (why are we using error port
for "normal" communication? Emacs?), but I think it might prove useful if
user keeps being reminded his environment is polluted or not as his
intentions might have been, or it could go "only" into guix|guix --help...

To doc or not to doc,
Drp
-- 
.sig place holder

[-- Attachment #1.2: Type: text/html, Size: 496 bytes --]

[-- Attachment #2: 0001-guix-Default-to-daemon-s-default-cores-setting-of-1.patch --]
[-- Type: application/octet-stream, Size: 1797 bytes --]

From 3693753aefc27b5a68a2b762feeebc41320e79ef Mon Sep 17 00:00:00 2001
From: nebuli <nebu@kipple>
Date: Wed, 26 Nov 2014 19:51:37 +0100
Subject: [PATCH 1/2] guix: Default to daemon's default --cores setting of 1.

* guix/scripts/build.scm (set-build-options-from-command-line):
  #:build-cores (or ... 1)
* guix/store.scm (set-build-options): (build-cores 1)
---
 guix/scripts/build.scm | 2 +-
 guix/store.scm         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index b4aa33b..3fb7aa8 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -129,7 +129,7 @@ options handled by 'set-build-options-from-command-line', and listed in
   ;; TODO: Add more options.
   (set-build-options store
                      #:keep-failed? (assoc-ref opts 'keep-failed?)
-                     #:build-cores (or (assoc-ref opts 'cores) 0)
+                     #:build-cores (or (assoc-ref opts 'cores) 1)
                      #:max-build-jobs (or (assoc-ref opts 'max-jobs) 1)
                      #:fallback? (assoc-ref opts 'fallback?)
                      #:use-substitutes? (assoc-ref opts 'substitutes?)
diff --git a/guix/store.scm b/guix/store.scm
index 571cc06..106475e 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -442,7 +442,7 @@ encoding conversion errors."
                             (build-verbosity 0)
                             (log-type 0)
                             (print-build-trace #t)
-                            (build-cores (current-processor-count))
+                            (build-cores 1)
                             (use-substitutes? #t)
                             (binary-caches '())) ; client "untrusted" cache URLs
   ;; Must be called after `open-connection'.
-- 
2.1.2


[-- Attachment #3: 0002-guix-scripts-Add-handling-of-options-from-GUIX_BUILD.patch --]
[-- Type: application/octet-stream, Size: 6512 bytes --]

From fa8738ff2cf48886c9ef8fbacfa806f547f3c3c8 Mon Sep 17 00:00:00 2001
From: nebuli <nebu@kipple>
Date: Thu, 27 Nov 2014 23:36:29 +0100
Subject: [PATCH 2/2] guix: scripts: Add handling of options from GUIX_BUILD
 environmental variable.

* guix/scripts/archive.scm (parse-options): (append args (args-from-env ...))
* guix/scripts/build.scm: ditto
* guix/scripts/environment.scm: ditto
* guix/scripts/package.scm: ditto
* guix/scripts/system.scm: ditto
* guix/utils.scm (args-from-env): New common function.
---
 guix/scripts/archive.scm     |  8 +++++++-
 guix/scripts/build.scm       |  8 +++++++-
 guix/scripts/environment.scm |  9 ++++++++-
 guix/scripts/package.scm     |  8 +++++++-
 guix/scripts/system.scm      |  8 +++++++-
 guix/utils.scm               | 15 +++++++++++++++
 6 files changed, 51 insertions(+), 5 deletions(-)

diff --git a/guix/scripts/archive.scm b/guix/scripts/archive.scm
index 84904e2..1ab4f86 100644
--- a/guix/scripts/archive.scm
+++ b/guix/scripts/archive.scm
@@ -293,7 +293,13 @@ the input port."
 (define (guix-archive . args)
   (define (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
+    (args-fold* (append args
+                        (args-from-env "GUIX_BUILD"
+                                       (lambda (var opts)
+                                         (format (current-error-port)
+                                                 (_ "guix archive: ~a: ~a~%")
+                                                 var opts))))
+                %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 3fb7aa8..57b75ca 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -401,7 +401,13 @@ 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
+                        (args-from-env "GUIX_BUILD"
+                                       (lambda (var opts)
+                                         (format (current-error-port)
+                                                 (_ "guix build: ~a: ~a~%")
+                                                 var opts))))
+                %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 81bad96..dfc6df4 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -213,7 +213,14 @@ packages."
 ;; Entry point.
 (define (guix-environment . args)
   (define (parse-options)
-    (args-fold* args %options
+    (args-fold* (append args
+                        (args-from-env
+                         "GUIX_BUILD"
+                         (lambda (var opts)
+                           (format (current-error-port)
+                                   (_ "guix environment: ~a: ~a~%")
+                                   var opts))))
+                %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 3a72053..70b37ec 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -668,7 +668,13 @@ removed from MANIFEST."
 (define (guix-package . args)
   (define (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
+    (args-fold* (append args
+                        (args-from-env "GUIX_BUILD"
+                                       (lambda (var opts)
+                                         (format (current-error-port)
+                                                 (_ "guix package: ~a: ~a~%")
+                                                 var opts))))
+                %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 398a5a3..fa00ae6 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -467,7 +467,13 @@ 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
+                        (args-from-env "GUIX_BUILD"
+                                       (lambda (var opts)
+                                         (format (current-error-port)
+                                                 (_ "guix system: ~a: ~a~%")
+                                                 var opts))))
+                %options
                 (lambda (opt name arg result)
                   (leave (_ "~A: unrecognized option~%") name))
                 (lambda (arg result)
diff --git a/guix/utils.scm b/guix/utils.scm
index 9b802b6..89e593c 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -72,6 +72,7 @@
             package-name->name+version
             string-tokenize*
             string-replace-substring
+            args-from-env
             file-extension
             file-sans-extension
             call-with-temporary-output-file
@@ -627,6 +628,20 @@ REPLACEMENT."
                        (substring str start index)
                        pieces))))))))
 
+(define (args-from-env var . rest)
+  "Retrieve value of environment variable denoted by string VAR in the form
+of a list of strings ('char-set:graphic' tokens) suitable for consumption by
+the fold-arg family of functions.  If VAR is defined, call car of a non-null
+REST on the VAR and result, otherwise return an empty list."
+  (let ((env-opts (getenv variable)))
+    (if env-opts
+        (let ((opts (string-tokenize env-opts char-set:graphic)))
+          (and (not (null? rest))
+               (apply (car rest)
+                      (list variable opts)))
+          opts)
+        '())))
+
 (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
-- 
2.1.2


       reply	other threads:[~2014-11-27 23:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAJ41eezW0KRVu6TBE0UeUVnNgqFSxgwML5p+FDd5h_bH3N_ghg@mail.gmail.com>
2014-11-27 23:13 ` Deck Pickard [this message]
2014-11-28 21:52   ` [PATCH] Core sanity and taking build options from environment Ludovic Courtès
2014-11-28 22:14     ` Andreas Enge
2014-11-30 17:17     ` Deck Pickard
2014-11-30 17:55       ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJ41eezNiGrwADtd_+fS76m2rQivqwuTz2B2if1RYLt+YLRdtg@mail.gmail.com \
    --to=deck.r.pickard@gmail.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).