Merge branch 'core-updates'
[jackhill/guix/guix.git] / build-aux / hydra / guix.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016 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 imagemagick)
51 (gnu packages graphviz)
52 (gnu packages man)
53 (srfi srfi-1)
54 (srfi srfi-26)
55 (ice-9 match))
56
57 ;; XXX: Debugging hack: since `hydra-eval-guile-jobs' redirects the output
58 ;; port to the bit bucket, let us write to the error port instead.
59 (setvbuf (current-error-port) _IOLBF)
60 (set-current-output-port (current-error-port))
61
62 (define* (package->alist store package system
63 #:optional (package-derivation package-derivation))
64 "Convert PACKAGE to an alist suitable for Hydra."
65 `((derivation . ,(derivation-file-name
66 (package-derivation store package system)))
67 (description . ,(package-synopsis package))
68 (long-description . ,(package-description package))
69 (license . ,(package-license package))
70 (home-page . ,(package-home-page package))
71 (maintainers . ("bug-guix@gnu.org"))))
72
73 (define (tarball-package checkout)
74 "Return a package that does `make distcheck' from CHECKOUT, a directory
75 containing a Git checkout of Guix."
76 (let ((guix (@@ (gnu packages package-management) guix)))
77 (dist-package (package
78 (inherit guix)
79 (arguments (package-arguments guix))
80 (native-inputs `(("imagemagick" ,imagemagick)
81 ,@(package-native-inputs guix))))
82 checkout
83
84 #:phases
85 '(modify-phases %dist-phases
86 (add-before 'build 'build-daemon
87 ;; Build 'guix-daemon' first so that help2man
88 ;; successfully creates 'guix-daemon.1'.
89 (lambda _
90 (let ((n (number->string
91 (parallel-job-count))))
92 (zero? (system* "make"
93 "nix/libstore/schema.sql.hh"
94 "guix-daemon" "-j" n)))))))))
95
96 (define (hydra-jobs store arguments)
97 "Return Hydra jobs."
98 (define systems
99 (match (filter-map (match-lambda
100 (('system . value)
101 value)
102 (_ #f))
103 arguments)
104 ((lst ..1)
105 lst)
106 (_
107 (list (%current-system)))))
108
109 (define guix-checkout
110 (assq-ref arguments 'guix))
111
112 (let ((guix (assq-ref guix-checkout 'file-name)))
113 (format (current-error-port) "using checkout ~s (~s)~%"
114 guix-checkout guix)
115 `((tarball . ,(cute package->alist store
116 (tarball-package guix)
117 (%current-system))))))