From: Mathieu Othacehe <othacehe@gnu.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 45104@debbugs.gnu.org
Subject: [bug#45104] pull: Add a "with-substitutes" option.
Date: Fri, 29 Jan 2021 14:23:18 +0100 [thread overview]
Message-ID: <871re3khbt.fsf@gnu.org> (raw)
In-Reply-To: <875z52loam.fsf@gnu.org> ("Ludovic Courtès"'s message of "Tue, 15 Dec 2020 23:03:45 +0100")
[-- Attachment #1: Type: text/plain, Size: 201 bytes --]
Hello,
Here's a patch implementing "channel-with-substitutes-available". The
following step will be to add the matching option for the "guix pull"
command, as discussed previously.
Thanks,
Mathieu
[-- Attachment #2: 0001-guix-channels-Introduce-channel-with-substitutes-ava.patch --]
[-- Type: text/x-diff, Size: 12121 bytes --]
From 8f93ced042f7f694c0c7a473686faa3c00497aa5 Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <othacehe@gnu.org>
Date: Fri, 29 Jan 2021 13:48:44 +0100
Subject: [PATCH] guix: channels: Introduce
"channel-with-substitutes-available".
* guix/channels.scm (find-latest-commit-with-substitutes,
channel-with-substitutes-available): New procedures.
* guix/scripts/pull.scm (guix-pull): Move "channel-list" call inside the
%current-system parameter scope.
* doc/guix.texi (Channels with substitutes): New section.
---
doc/guix.texi | 27 ++++++++++-
guix/channels.scm | 29 +++++++++++-
guix/scripts/pull.scm | 103 +++++++++++++++++++++---------------------
3 files changed, 106 insertions(+), 53 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index ff9e8da2e0..6587a49d0e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -40,7 +40,7 @@ Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Julien Lepiller@*
Copyright @copyright{} 2016 Alex ter Weele@*
Copyright @copyright{} 2016, 2017, 2018, 2019 Christopher Baines@*
Copyright @copyright{} 2017, 2018, 2019 Clément Lassieur@*
-Copyright @copyright{} 2017, 2018, 2020 Mathieu Othacehe@*
+Copyright @copyright{} 2017, 2018, 2020, 2021 Mathieu Othacehe@*
Copyright @copyright{} 2017 Federico Beffa@*
Copyright @copyright{} 2017, 2018 Carlo Zancanaro@*
Copyright @copyright{} 2017 Thomas Danckaert@*
@@ -245,6 +245,7 @@ Channels
* Specifying Channel Authorizations:: Defining channel authors authorizations.
* Primary URL:: Distinguishing mirror to original.
* Writing Channel News:: Communicating information to channel's users.
+* Channels with substitutes:: Using channels with available substitutes.
Development
@@ -4919,6 +4920,7 @@ updates.
* Specifying Channel Authorizations:: Defining channel authors authorizations.
* Primary URL:: Distinguishing mirror to original.
* Writing Channel News:: Communicating information to channel's users.
+* Channels with substitutes:: Using channels with available substitutes.
@end menu
@node Specifying Additional Channels
@@ -5390,6 +5392,29 @@ xgettext -o news.po -l scheme -ken etc/news.txt
To sum up, yes, you could use your channel as a blog. But beware, this
is @emph{not quite} what your users might expect.
+@node Channels with substitutes
+@section Channels with substitutes
+
+When running @command{guix pull}, Guix will first compile the
+definitions of every available package. This is an expensive operation
+for which substitutes (@pxref{Substitutes}) may be available. The
+following snippet in @file{channels.scm} will ensure that @command{guix
+pull} uses the latest commit with available substitutes for the package
+definitions. This is done by querying the continuous integration
+server at @url{https://ci.guix.gnu.org}.
+
+Be careful, this does not mean that all the packages that you will
+install after running @command{guix pull} will have available
+substitutes. It only ensures that @command{guix pull} will not try to
+compile package definitions. This is particularly useful when using
+machines with limited resources.
+
+@lisp
+(list
+ (channel-with-substitutes-available
+ %default-guix-channel
+ "https://ci.guix.gnu.org"))
+@end lisp
@c *********************************************************************
@node Development
diff --git a/guix/channels.scm b/guix/channels.scm
index 0c84eed477..817e30d738 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -20,6 +20,7 @@
(define-module (guix channels)
#:use-module (git)
+ #:use-module (guix ci)
#:use-module (guix git)
#:use-module (guix git-authenticate)
#:use-module ((guix openpgp)
@@ -98,7 +99,9 @@
channel-news-entry-title
channel-news-entry-body
- channel-news-for-commit))
+ channel-news-for-commit
+
+ channel-with-substitutes-available))
;;; Commentary:
;;;
@@ -1044,6 +1047,30 @@ NEW. When OLD is omitted or is #f, return all the news entries of CHANNEL."
'()
(apply throw key error rest)))))
+(define (find-latest-commit-with-substitutes url)
+ (let* ((job-name (string-append "guix." (%current-system)))
+ (build (match (latest-builds url 1
+ #:job job-name
+ #:status 0) ;success
+ ((build) build)
+ (_ #f)))
+ (evaluation (and build
+ (evaluation url (build-evaluation build))))
+ (commit (and evaluation
+ (match (evaluation-checkouts evaluation)
+ ((checkout)
+ (checkout-commit checkout))))))
+ commit))
+
+(define (channel-with-substitutes-available chan url)
+ (let ((commit (find-latest-commit-with-substitutes url)))
+ (unless commit
+ (warning (G_ "could not find available substitutes at ~a~%")
+ url))
+ (channel
+ (inherit chan)
+ (commit commit))))
+
;;; Local Variables:
;;; eval: (put 'with-guile 'scheme-indent-function 1)
;;; End:
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 83cdc1d1eb..4e0ab5d341 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -765,60 +765,61 @@ Use '~/.config/guix/channels.scm' instead."))
#:argument-handler no-arguments))
(substitutes? (assoc-ref opts 'substitutes?))
(dry-run? (assoc-ref opts 'dry-run?))
- (channels (channel-list opts))
(profile (or (assoc-ref opts 'profile) %current-profile))
(current-channels (profile-channels profile))
(validate-pull (assoc-ref opts 'validate-pull))
(authenticate? (assoc-ref opts 'authenticate-channels?)))
- (cond ((assoc-ref opts 'query)
- (process-query opts profile))
- ((assoc-ref opts 'generation)
- (process-generation-change opts profile))
- (else
- (with-store store
- (with-status-verbosity (assoc-ref opts 'verbosity)
- (parameterize ((%current-system (assoc-ref opts 'system))
- (%graft? (assoc-ref opts 'graft?)))
- (with-build-handler (build-notifier #:use-substitutes?
- substitutes?
- #:verbosity
- (assoc-ref opts 'verbosity)
- #:dry-run? dry-run?)
- (set-build-options-from-command-line store opts)
- (ensure-default-profile)
- (honor-x509-certificates store)
-
- (let ((instances
- (latest-channel-instances store channels
- #:current-channels
- current-channels
- #:validate-pull
- validate-pull
- #:authenticate?
- authenticate?)))
- (format (current-error-port)
- (N_ "Building from this channel:~%"
- "Building from these channels:~%"
- (length instances)))
- (for-each (lambda (instance)
- (let ((channel
- (channel-instance-channel instance)))
- (format (current-error-port)
- " ~10a~a\t~a~%"
- (channel-name channel)
- (channel-url channel)
- (string-take
- (channel-instance-commit instance)
- 7))))
- instances)
- (parameterize ((%guile-for-build
- (package-derivation
- store
- (if (assoc-ref opts 'bootstrap?)
- %bootstrap-guile
- (default-guile)))))
- (with-profile-lock profile
- (run-with-store store
- (build-and-install instances profile)))))))))))))))
+ (cond
+ ((assoc-ref opts 'query)
+ (process-query opts profile))
+ ((assoc-ref opts 'generation)
+ (process-generation-change opts profile))
+ (else
+ (with-store store
+ (with-status-verbosity (assoc-ref opts 'verbosity)
+ (parameterize ((%current-system (assoc-ref opts 'system))
+ (%graft? (assoc-ref opts 'graft?)))
+ (with-build-handler (build-notifier #:use-substitutes?
+ substitutes?
+ #:verbosity
+ (assoc-ref opts 'verbosity)
+ #:dry-run? dry-run?)
+ (set-build-options-from-command-line store opts)
+ (ensure-default-profile)
+ (honor-x509-certificates store)
+
+ (let* ((channels (channel-list opts))
+ (instances
+ (latest-channel-instances store channels
+ #:current-channels
+ current-channels
+ #:validate-pull
+ validate-pull
+ #:authenticate?
+ authenticate?)))
+ (format (current-error-port)
+ (N_ "Building from this channel:~%"
+ "Building from these channels:~%"
+ (length instances)))
+ (for-each (lambda (instance)
+ (let ((channel
+ (channel-instance-channel instance)))
+ (format (current-error-port)
+ " ~10a~a\t~a~%"
+ (channel-name channel)
+ (channel-url channel)
+ (string-take
+ (channel-instance-commit instance)
+ 7))))
+ instances)
+ (parameterize ((%guile-for-build
+ (package-derivation
+ store
+ (if (assoc-ref opts 'bootstrap?)
+ %bootstrap-guile
+ (default-guile)))))
+ (with-profile-lock profile
+ (run-with-store store
+ (build-and-install instances profile)))))))))))))))
;;; pull.scm ends here
--
2.29.2
next prev parent reply other threads:[~2021-01-29 13:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-07 15:39 [bug#45104] pull: Add a "with-substitutes" option Mathieu Othacehe
2020-12-07 17:05 ` zimoun
2020-12-08 19:17 ` Christopher Baines
2020-12-14 11:05 ` Ludovic Courtès
2020-12-14 11:39 ` zimoun
2020-12-15 10:30 ` Mathieu Othacehe
2020-12-15 12:51 ` zimoun
2020-12-15 10:24 ` Mathieu Othacehe
2020-12-15 22:03 ` Ludovic Courtès
2021-01-29 13:23 ` Mathieu Othacehe [this message]
2021-01-29 13:36 ` Mathieu Othacehe
2021-01-31 16:18 ` Ludovic Courtès
2021-01-31 17:37 ` bug#45104: " Mathieu Othacehe
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=871re3khbt.fsf@gnu.org \
--to=othacehe@gnu.org \
--cc=45104@debbugs.gnu.org \
--cc=ludo@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).