1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
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.
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.
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/>.
20 ;;; This file defines build jobs for the Hydra continuation integration
24 ;; Attempt to use our very own Guix modules.
25 (eval-when (compile load eval)
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)
32 (and=> (assoc-ref (current-source-location) 'filename)
34 (let ((dir (string-append (dirname file) "/../..")))
35 (format (current-error-port) "prepending ~s to the load path~%"
37 (set! %load-path (cons dir %load-path))))))
39 (use-modules (guix config)
45 ((guix licenses) #:select (gpl3+))
46 ((guix utils) #:select (%current-system))
47 ((guix scripts system) #:select (read-operating-system))
53 (gnu packages gettext)
54 (gnu packages compression)
55 (gnu packages multiprecision)
56 (gnu packages make-bootstrap)
57 (gnu packages package-management)
66 ;; XXX: Debugging hack: since `hydra-eval-guile-jobs' redirects the output
67 ;; port to the bit bucket, let us write to the error port instead.
68 (setvbuf (current-error-port) _IOLBF)
69 (set-current-output-port (current-error-port))
71 (define* (package->alist store package system
72 #:optional (package-derivation package-derivation))
73 "Convert PACKAGE to an alist suitable for Hydra."
74 (parameterize ((%graft? #f))
75 `((derivation . ,(derivation-file-name
76 (package-derivation store package system
78 (description . ,(package-synopsis package))
79 (long-description . ,(package-description package))
80 (license . ,(package-license package))
81 (home-page . ,(package-home-page package))
82 (maintainers . ("bug-guix@gnu.org"))
83 (max-silent-time . ,(or (assoc-ref (package-properties package)
85 3600)) ;1 hour by default
86 (timeout . ,(or (assoc-ref (package-properties package) 'timeout)
87 72000))))) ;20 hours by default
89 (define (package-job store job-name package system)
90 "Return a job called JOB-NAME that builds PACKAGE on SYSTEM."
91 (let ((job-name (symbol-append job-name (string->symbol ".")
92 (string->symbol system))))
93 `(,job-name . ,(cut package->alist store package system))))
95 (define (package-cross-job store job-name package target system)
96 "Return a job called TARGET.JOB-NAME that cross-builds PACKAGE for TARGET on
98 `(,(symbol-append (string->symbol target) (string->symbol ".") job-name
99 (string->symbol ".") (string->symbol system)) .
100 ,(cute package->alist store package system
101 (lambda* (store package system #:key graft?)
102 (package-cross-derivation store package target system
105 (define %core-packages
106 ;; Note: Don't put the '-final' package variants because (1) that's
107 ;; implicit, and (2) they cannot be cross-built (due to the explicit input
109 (list gcc-4.8 gcc-4.9 gcc-5 glibc binutils
110 gmp mpfr mpc coreutils findutils diffutils patch sed grep
111 gawk gnu-gettext hello guile-2.0 zlib gzip xz
112 %bootstrap-binaries-tarball
113 %binutils-bootstrap-tarball
114 (%glibc-bootstrap-tarball)
115 %gcc-bootstrap-tarball
116 %guile-bootstrap-tarball
117 %bootstrap-tarballs))
119 (define %packages-to-cross-build
122 (define %cross-targets
123 '("mips64el-linux-gnu"
124 "mips64el-linux-gnuabi64"
125 "arm-linux-gnueabihf"
127 "i586-pc-gnu" ;aka. GNU/Hurd
130 (define %guixsd-supported-systems
131 '("x86_64-linux" "i686-linux"))
133 (define (qemu-jobs store system)
134 "Return a list of jobs that build QEMU images for SYSTEM."
135 (define (->alist drv)
136 `((derivation . ,(derivation-file-name drv))
137 (description . "Stand-alone QEMU image of the GNU system")
138 (long-description . "This is a demo stand-alone QEMU image of the GNU
141 (home-page . ,%guix-home-page-url)
142 (maintainers . ("bug-guix@gnu.org"))))
144 (define (->job name drv)
145 (let ((name (symbol-append name (string->symbol ".")
146 (string->symbol system))))
147 `(,name . ,(lambda ()
148 (parameterize ((%graft? #f))
154 (if (member system %guixsd-supported-systems)
155 (list (->job 'usb-image
156 (run-with-store store
158 (set-guile-for-build (default-guile))
159 (system-disk-image installation-os
164 (define (system-test-jobs store system)
165 "Return a list of jobs for the system tests."
166 (define (test->thunk test)
169 (run-with-store store
171 (set-current-system system)
173 (set-guile-for-build (default-guile))
174 (system-test-value test))))
176 `((derivation . ,(derivation-file-name drv))
177 (description . ,(format #f "GuixSD '~a' system test"
178 (system-test-name test)))
179 (long-description . ,(system-test-description test))
181 (home-page . ,%guix-home-page-url)
182 (maintainers . ("bug-guix@gnu.org")))))
185 (let ((name (string->symbol
186 (string-append "test." (system-test-name test)
188 (cons name (test->thunk test))))
190 (if (member system %guixsd-supported-systems)
191 (map ->job (all-system-tests))
194 (define (tarball-jobs store system)
195 "Return Hydra jobs to build the self-contained Guix binary tarball."
196 (define (->alist drv)
197 `((derivation . ,(derivation-file-name drv))
198 (description . "Stand-alone binary Guix tarball")
199 (long-description . "This is a tarball containing binaries of Guix and
200 all its dependencies, and ready to be installed on non-GuixSD distributions.")
202 (home-page . ,%guix-home-page-url)
203 (maintainers . ("bug-guix@gnu.org"))))
205 (define (->job name drv)
206 (let ((name (symbol-append name (string->symbol ".")
207 (string->symbol system))))
208 `(,name . ,(lambda ()
209 (parameterize ((%graft? #f))
212 ;; XXX: Add a job for the stable Guix?
213 (list (->job 'binary-tarball
214 (run-with-store store
216 (set-guile-for-build (default-guile))
217 (self-contained-tarball))
221 ;; Return the name of a package's job.
222 (compose string->symbol package-full-name))
227 (append-map (match-lambda
229 (match (package-transitive-inputs package)
230 (((_ inputs _ ...) ...)
233 (lambda (store package system)
234 "Return a job for PACKAGE on SYSTEM, or #f if this combination is not
236 (cond ((member package base-packages)
238 ((supported-package? package system)
239 (package-job store (job-name package) package system))
245 ;;; Hydra entry point.
248 (define (hydra-jobs store arguments)
251 (match (assoc-ref arguments 'subset)
252 ("core" 'core) ; only build core packages
253 (_ 'all))) ; build everything
255 (define (cross-jobs system)
256 (define (from-32-to-64? target)
257 ;; Return true if SYSTEM is 32-bit and TARGET is 64-bit. This hack
258 ;; prevents known-to-fail cross-builds from i686-linux or armhf-linux to
259 ;; mips64el-linux-gnuabi64.
260 (and (or (string-prefix? "i686-" system)
261 (string-prefix? "armhf-" system))
262 (string-suffix? "64" target)))
264 (define (same? target)
265 ;; Return true if SYSTEM and TARGET are the same thing. This is so we
266 ;; don't try to cross-compile to 'mips64el-linux-gnu' from
268 (string-contains target system))
270 (define (pointless? target)
271 ;; Return #t if it makes no sense to cross-build to TARGET from SYSTEM.
272 (and (string-contains target "mingw")
273 (not (string=? "x86_64-linux" system))))
275 (define (either proc1 proc2 proc3)
277 (or (proc1 x) (proc2 x) (proc3 x))))
279 (append-map (lambda (target)
280 (map (lambda (package)
281 (package-cross-job store (job-name package)
282 package target system))
283 %packages-to-cross-build))
284 (remove (either from-32-to-64? same? pointless?)
287 ;; Turn off grafts. Grafting is meant to happen on the user's machines.
288 (parameterize ((%graft? #f))
289 ;; Return one job for each package, except bootstrap packages.
290 (append-map (lambda (system)
293 ;; Build everything, including replacements.
294 (let ((all (fold-packages
295 (lambda (package result)
296 (if (package-replacement package)
298 (package-replacement package)
300 (cons package result)))
302 (job (lambda (package)
303 (package->job store package
305 (append (filter-map job all)
306 (qemu-jobs store system)
307 (system-test-jobs store system)
308 (tarball-jobs store system)
309 (cross-jobs system))))
311 ;; Build core packages only.
312 (append (map (lambda (package)
313 (package-job store (job-name package)
316 (cross-jobs system)))
318 (error "unknown subset" subset))))
319 %hydra-supported-systems)))