unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Pierre Neidhardt <mail@ambrevar.xyz>
Cc: help-guix <help-guix@gnu.org>
Subject: Re: Guile snippet to get latest "guix pull" commit with prebuilt binaries
Date: Tue, 12 Feb 2019 17:34:54 +0100	[thread overview]
Message-ID: <87k1i5hsnl.fsf@gnu.org> (raw)
In-Reply-To: <87sgx36thh.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Tue, 05 Feb 2019 00:09:46 +0100")

[-- Attachment #1: Type: text/plain, Size: 386 bytes --]

Hello!

Pierre Neidhardt <mail@ambrevar.xyz> skribis:

> Ludo told me he had a Guile snippet to find the last Guix commits  with
> enough(?) pre-built binaries.  (Which is quite useful for a "guix pull".)
>
> Ludo, anyone, would you like to share? :)

Here’s the file you’d drop as ~/.config/guix/channels.scm or pass to
‘guix pull -C’ (it expects Guile-JSON 1.x):


[-- Attachment #2: the file --]
[-- Type: text/plain, Size: 1894 bytes --]

(use-modules (guix http-client)
             (json)
             (srfi srfi-1)
             (ice-9 match))

(define (latest-evaluations jobset)
  "Return the latest evaluations of JOBSET."
  (filter (lambda (json)
            (string=? (hash-ref json "specification") jobset))
          (json->scm
           (http-fetch
            "https://berlin.guixsd.org/api/evaluations?nr=30"))))

(define (evaluation-complete? number)
  "Return true if evaluation NUMBER completed and all its builds were
successful."
  (let ((builds (json->scm
                 (http-fetch
                  (string-append
                   "https://berlin.guixsd.org/api/latestbuilds?nr=30&evaluation="
                   (number->string number))))))
    (every (lambda (build)
             ;; Zero means build success.
             (= (hash-ref build "buildstatus") 0))
           builds)))

(define (latest-commit-successfully-built)
  "Return the latest commit for which substitutes are (potentially)
available."
  (let* ((evaluations (latest-evaluations "guix-modular-master"))
         (candidates  (filter-map (lambda (json)
                                    (match (hash-ref json "checkouts")
                                      ((checkout)
                                       (cons (hash-ref json "id")
                                             (hash-ref checkout "commit")))
                                      (_ #f)))
                                  evaluations)))
    (any (match-lambda
            ((evaluation . commit)
             (and (evaluation-complete? evaluation)
                  commit)))
          candidates)))

;; Pull the latest commit fully built on berlin.guixsd.org.
;; WARNING: This could downgrade your system!
(list (channel
       (name 'guix)
       (url "https://git.savannah.gnu.org/git/guix.git")
       (commit (pk 'commit (latest-commit-successfully-built)))))

[-- Attachment #3: Type: text/plain, Size: 143 bytes --]


It looks for a commit for which Guix itself is built.

Use with care as this could prevent you from getting security updates!

Ludo’.

  parent reply	other threads:[~2019-02-12 16:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-04 23:09 Guile snippet to get latest "guix pull" commit with prebuilt binaries Pierre Neidhardt
2019-02-05  4:58 ` swedebugia
2019-02-12 16:34 ` Ludovic Courtès [this message]
2019-02-12 19:22   ` Pierre Neidhardt

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=87k1i5hsnl.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=help-guix@gnu.org \
    --cc=mail@ambrevar.xyz \
    /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.
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).