From 041a9466ea23d6ae811491bcf529bf9487317b48 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 29 Jan 2021 13:48:44 +0100 Subject: 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. --- guix/ci.scm | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'guix/ci.scm') diff --git a/guix/ci.scm b/guix/ci.scm index f429bf198f..95325b4bfe 100644 --- a/guix/ci.scm +++ b/guix/ci.scm @@ -19,9 +19,11 @@ (define-module (guix ci) #:use-module (guix http-client) + #:use-module (guix utils) #:use-module (json) #:use-module (srfi srfi-1) #:use-module (ice-9 match) + #:autoload (guix channels) (channel) #:export (build-product? build-product-id build-product-type @@ -52,7 +54,9 @@ latest-builds evaluation latest-evaluations - evaluations-for-commit)) + evaluations-for-commit + + channel-with-substitutes-available)) ;;; Commentary: ;;; @@ -165,3 +169,35 @@ as one of their inputs." (string=? (checkout-commit checkout) commit)) (evaluation-checkouts evaluation))) (latest-evaluations url limit))) + +(define (find-latest-commit-with-substitutes url) + "Return the latest commit with available substitutes for the Guix package +definitions at URL. Return false if no commit were found." + (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) + "Return a channel inheriting from CHAN but which commit field is set to the +latest commit with available substitutes for the Guix package definitions at +URL. The current system is taken into account. + +If no commit with available substitutes were found, the commit field is set to +false and a warning message is printed." + (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)))) -- cgit v1.2.3 From 246c0c60da7623fdf8956687a1c11299056d4b1a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 31 Jan 2021 21:48:26 +0100 Subject: ci: Add missing imports. This is a followup to 041a9466ea23d6ae811491bcf529bf9487317b48. * guix/ci.scm: Add missing imports. * guix/channels.scm: Remove (guix ci) import. --- guix/channels.scm | 1 - guix/ci.scm | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'guix/ci.scm') diff --git a/guix/channels.scm b/guix/channels.scm index 9ab8cd8749..0c84eed477 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -20,7 +20,6 @@ (define-module (guix channels) #:use-module (git) - #:use-module (guix ci) #:use-module (guix git) #:use-module (guix git-authenticate) #:use-module ((guix openpgp) diff --git a/guix/ci.scm b/guix/ci.scm index 95325b4bfe..f04109112c 100644 --- a/guix/ci.scm +++ b/guix/ci.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2018, 2019, 2020 Ludovic Courtès +;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2020 Mathieu Othacehe ;;; ;;; This file is part of GNU Guix. @@ -23,6 +23,8 @@ #:use-module (json) #:use-module (srfi srfi-1) #:use-module (ice-9 match) + #:use-module (guix i18n) + #:use-module (guix diagnostics) #:autoload (guix channels) (channel) #:export (build-product? build-product-id -- cgit v1.2.3