From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#22629: =?UTF-8?Q?=E2=80=9CStable=E2=80=9D?= branch Date: Mon, 03 Sep 2018 22:27:25 +0200 Message-ID: <87h8j6wclu.fsf@gnu.org> References: <87vb5vsffd.fsf@gnu.org> <87pny2iks2.fsf@gnu.org> <877ekagtg9.fsf@netris.org> <87zhx5msfl.fsf@pompo.co> <87lg8pccys.fsf_-_@netris.org> <87zhx59gh3.fsf@elephly.net> <875zzs9wzl.fsf@netris.org> <874lfcxd2v.fsf_-_@gnu.org> <87wos8lzcj.fsf@pompo.co> <878t4nqzqv.fsf@gnu.org> <87r2iau0wz.fsf@pompo.co> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwvS7-0007W4-0b for bug-guix@gnu.org; Mon, 03 Sep 2018 16:28:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fwvS6-0000lb-1z for bug-guix@gnu.org; Mon, 03 Sep 2018 16:28:02 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:39607) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fwvS5-0000lP-RP for bug-guix@gnu.org; Mon, 03 Sep 2018 16:28:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fwvS5-0006Q7-Nn for bug-guix@gnu.org; Mon, 03 Sep 2018 16:28:01 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87r2iau0wz.fsf@pompo.co> (Alex Sassmannshausen's message of "Mon, 03 Sep 2018 16:10:36 +0200") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Alex Sassmannshausen Cc: 26608@debbugs.gnu.org, 22629@debbugs.gnu.org, 32022@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Alex Sassmannshausen skribis: > Ludovic Court=C3=A8s writes: [...] >> I just had a bright idea (yes!): this can be addressed by writing >> something like this in ~/.config/guix/channels.scm: >> >> (map latest-commit-with-substitutes-available >> %default-channels) >> >> The hypothetical =E2=80=98latest-commit-with-substitutes-available=E2=80= =99 would use >> (git) and (guix ci) to find the latest commit for which substitutes of >> interest are available, and would return: >> >> (channel >> ;; =E2=80=A6 >> (commit "cabbag3")) ;the ideal commit The code below is an illustration of that. If you install it as ~/.config/guix/channels.scm, =E2=80=98guix pull=E2=80=99 will pull the late= st commit that was fully built on berlin.guixsd.org (see ), meaning that substitutes for Guix itself should be available, unless =E2=80=98guix publi= sh=E2=80=99 hasn=E2=80=99t =E2=80=9Cbaked=E2=80=9D them yet. It takes two GETs and ~1s to do that here. Ludo=E2=80=99. --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=channels-test.scm Content-Description: the channels config (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))))) --=-=-=--