hydra: Support per-package absolute build timeouts.
[jackhill/guix/guix.git] / build-aux / hydra / guix.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 ;;;
20 ;;; This file defines build jobs of Guix itself for the Hydra continuation
21 ;;; integration tool.
22 ;;;
23
24 ;; Attempt to use our very own Guix modules.
25 (eval-when (compile load eval)
26
27 ;; Ignore any available .go, and force recompilation. This is because our
28 ;; checkout in the store has mtime set to the epoch, and thus .go files look
29 ;; newer, even though they may not correspond.
30 (set! %fresh-auto-compile #t)
31
32 ;; Display which files are loaded.
33 (set! %load-verbosely #t)
34
35 (and=> (assoc-ref (current-source-location) 'filename)
36 (lambda (file)
37 (let ((dir (string-append (dirname file) "/../..")))
38 (format (current-error-port) "prepending ~s to the load path~%"
39 dir)
40 (set! %load-path (cons dir %load-path))))))
41
42
43 (use-modules (guix store)
44 (guix packages)
45 (guix utils)
46 (guix derivations)
47 (guix build-system gnu)
48 (gnu packages version-control)
49 (gnu packages package-management)
50 (gnu packages graphviz)
51 (srfi srfi-1)
52 (srfi srfi-26)
53 (ice-9 match))
54
55 ;; XXX: Debugging hack: since `hydra-eval-guile-jobs' redirects the output
56 ;; port to the bit bucket, let us write to the error port instead.
57 (setvbuf (current-error-port) _IOLBF)
58 (set-current-output-port (current-error-port))
59
60 (define* (package->alist store package system
61 #:optional (package-derivation package-derivation))
62 "Convert PACKAGE to an alist suitable for Hydra."
63 `((derivation . ,(derivation-file-name
64 (package-derivation store package system)))
65 (description . ,(package-synopsis package))
66 (long-description . ,(package-description package))
67 (license . ,(package-license package))
68 (home-page . ,(package-home-page package))
69 (maintainers . ("bug-guix@gnu.org"))))
70
71 (define (tarball-package checkout)
72 "Return a package that does `make distcheck' from CHECKOUT, a directory
73 containing a Git checkout of Guix."
74 (dist-package guix checkout))
75
76 (define (hydra-jobs store arguments)
77 "Return Hydra jobs."
78 (define systems
79 (match (filter-map (match-lambda
80 (('system . value)
81 value)
82 (_ #f))
83 arguments)
84 ((lst ..1)
85 lst)
86 (_
87 (list (%current-system)))))
88
89 (define guix-checkout
90 (assq-ref arguments 'guix))
91
92 (let ((guix (assq-ref guix-checkout 'file-name)))
93 (format (current-error-port) "using checkout ~s (~s)~%"
94 guix-checkout guix)
95 `((tarball . ,(cute package->alist store
96 (tarball-package guix)
97 (%current-system))))))