From 581f9eb84532b5682f48926e868456e2457fe54c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Fri, 12 Apr 2013 15:43:55 +0200
Subject: [PATCH] guix package: Add `--no-substitutes'.

* guix/scripts/package.scm (%default-options): Add `substitutes?'.
  (show-help, %options): Add and document `--no-substitutes'.
  (guix-package): Call `set-build-options' to honor `substitutes?'.
---
 doc/guix.texi            |  3 +++
 guix/scripts/package.scm | 13 ++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 1be172c3f66..c91bc2021df 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -570,6 +570,9 @@ Use @var{profile} instead of the user's default profile.
 @itemx -n
 Show what would be done without actually doing it.
 
+@item --no-substitutes
+Build instead of resorting to pre-built substitutes.
+
 @item --verbose
 Produce verbose output.  In particular, emit the environment's build log
 on the standard error port.
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 89708ccc497..ba75cd778c1 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -313,7 +313,8 @@ (define (check-package-freshness package)
 
 (define %default-options
   ;; Alist of default option values.
-  `((profile . ,%current-profile)))
+  `((profile . ,%current-profile)
+    (substitutes? . #t)))
 
 (define (show-help)
   (display (_ "Usage: guix package [OPTION]... PACKAGES...
@@ -334,6 +335,8 @@ (define (show-help)
   -p, --profile=PROFILE  use PROFILE instead of the user's default profile"))
   (display (_ "
   -n, --dry-run          show what would be done without actually doing it"))
+  (display (_ "
+      --no-substitutes   build instead of resorting to pre-built substitutes"))
   (display (_ "
       --bootstrap        use the bootstrap Guile to build the profile"))
   (display (_ "
@@ -388,6 +391,10 @@ (define %options
         (option '(#\n "dry-run") #f #f
                 (lambda (opt name arg result)
                   (alist-cons 'dry-run? #t result)))
+        (option '("no-substitutes") #f #f
+                (lambda (opt name arg result)
+                  (alist-cons 'substitutes? #f
+                              (alist-delete 'substitutes? result))))
         (option '("bootstrap") #f #f
                 (lambda (opt name arg result)
                   (alist-cons 'bootstrap? #t result)))
@@ -750,6 +757,10 @@ (define (process-query opts)
     (or (process-query opts)
         (with-error-handling
           (parameterize ((%store (open-connection)))
+            (set-build-options (%store)
+                               #:use-substitutes?
+                               (assoc-ref opts 'substitutes?))
+
             (parameterize ((%guile-for-build
                             (package-derivation (%store)
                                                 (if (assoc-ref opts 'bootstrap?)
-- 
GitLab