From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Subject: Re: Guile snippet to get latest "guix pull" commit with prebuilt binaries Date: Tue, 12 Feb 2019 17:34:54 +0100 Message-ID: <87k1i5hsnl.fsf@gnu.org> References: <87sgx36thh.fsf@ambrevar.xyz> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:35537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtb26-0005AH-Rj for help-guix@gnu.org; Tue, 12 Feb 2019 11:35:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtb1Q-0000nq-KF for help-guix@gnu.org; Tue, 12 Feb 2019 11:35:01 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:51042) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtb1P-0000lX-Mt for help-guix@gnu.org; Tue, 12 Feb 2019 11:35:00 -0500 In-Reply-To: <87sgx36thh.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Tue, 05 Feb 2019 00:09:46 +0100") List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: Pierre Neidhardt Cc: help-guix --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello! Pierre Neidhardt 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=E2=80=99s the file you=E2=80=99d drop as ~/.config/guix/channels.scm o= r pass to =E2=80=98guix pull -C=E2=80=99 (it expects Guile-JSON 1.x): --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=stable-channels.scm Content-Description: the file (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))))) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable It looks for a commit for which Guix itself is built. Use with care as this could prevent you from getting security updates! Ludo=E2=80=99. --=-=-=--