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"
128 "i586-pc-gnu" ;aka. GNU/Hurd
131 (define %guixsd-supported-systems
132 '("x86_64-linux" "i686-linux"))
134 (define (qemu-jobs store system)
135 "Return a list of jobs that build QEMU images for SYSTEM."
136 (define (->alist drv)
137 `((derivation . ,(derivation-file-name drv))
138 (description . "Stand-alone QEMU image of the GNU system")
139 (long-description . "This is a demo stand-alone QEMU image of the GNU
142 (home-page . ,%guix-home-page-url)
143 (maintainers . ("bug-guix@gnu.org"))))
145 (define (->job name drv)
146 (let ((name (symbol-append name (string->symbol ".")
147 (string->symbol system))))
148 `(,name . ,(lambda ()
149 (parameterize ((%graft? #f))
155 (if (member system %guixsd-supported-systems)
156 (list (->job 'usb-image
157 (run-with-store store
159 (set-guile-for-build (default-guile))
160 (system-disk-image installation-os
165 (define (system-test-jobs store system)
166 "Return a list of jobs for the system tests."
167 (define (test->thunk test)
170 (run-with-store store
172 (set-current-system system)
174 (set-guile-for-build (default-guile))
175 (system-test-value test))))
177 `((derivation . ,(derivation-file-name drv))
178 (description . ,(format #f "GuixSD '~a' system test"
179 (system-test-name test)))
180 (long-description . ,(system-test-description test))
182 (home-page . ,%guix-home-page-url)
183 (maintainers . ("bug-guix@gnu.org")))))
186 (let ((name (string->symbol
187 (string-append "test." (system-test-name test)
189 (cons name (test->thunk test))))
191 (if (member system %guixsd-supported-systems)
192 (map ->job (all-system-tests))
195 (define (tarball-jobs store system)
196 "Return Hydra jobs to build the self-contained Guix binary tarball."
197 (define (->alist drv)
198 `((derivation . ,(derivation-file-name drv))
199 (description . "Stand-alone binary Guix tarball")
200 (long-description . "This is a tarball containing binaries of Guix and
201 all its dependencies, and ready to be installed on non-GuixSD distributions.")
203 (home-page . ,%guix-home-page-url)
204 (maintainers . ("bug-guix@gnu.org"))))
206 (define (->job name drv)
207 (let ((name (symbol-append name (string->symbol ".")
208 (string->symbol system))))
209 `(,name . ,(lambda ()
210 (parameterize ((%graft? #f))
213 ;; XXX: Add a job for the stable Guix?
214 (list (->job 'binary-tarball
215 (run-with-store store
217 (set-guile-for-build (default-guile))
218 (self-contained-tarball))
222 ;; Return the name of a package's job.
223 (compose string->symbol package-full-name))
228 (append-map (match-lambda
230 (match (package-transitive-inputs package)
231 (((_ inputs _ ...) ...)
234 (lambda (store package system)
235 "Return a job for PACKAGE on SYSTEM, or #f if this combination is not
237 (cond ((member package base-packages)
239 ((supported-package? package system)
240 (package-job store (job-name package) package system))
246 ;;; Hydra entry point.
249 (define (hydra-jobs store arguments)
252 (match (assoc-ref arguments 'subset)
253 ("core" 'core) ; only build core packages
254 (_ 'all))) ; build everything
256 (define (cross-jobs system)
257 (define (from-32-to-64? target)
258 ;; Return true if SYSTEM is 32-bit and TARGET is 64-bit. This hack
259 ;; prevents known-to-fail cross-builds from i686-linux or armhf-linux to
260 ;; mips64el-linux-gnuabi64.
261 (and (or (string-prefix? "i686-" system)
262 (string-prefix? "armhf-" system))
263 (string-suffix? "64" target)))
265 (define (same? target)
266 ;; Return true if SYSTEM and TARGET are the same thing. This is so we
267 ;; don't try to cross-compile to 'mips64el-linux-gnu' from
269 (string-contains target system))
271 (define (pointless? target)
272 ;; Return #t if it makes no sense to cross-build to TARGET from SYSTEM.
273 (and (string-contains target "mingw")
274 (not (string=? "x86_64-linux" system))))
276 (define (either proc1 proc2 proc3)
278 (or (proc1 x) (proc2 x) (proc3 x))))
280 (append-map (lambda (target)
281 (map (lambda (package)
282 (package-cross-job store (job-name package)
283 package target system))
284 %packages-to-cross-build))
285 (remove (either from-32-to-64? same? pointless?)
288 ;; Turn off grafts. Grafting is meant to happen on the user's machines.
289 (parameterize ((%graft? #f))
290 ;; Return one job for each package, except bootstrap packages.
291 (append-map (lambda (system)
294 ;; Build everything, including replacements.
295 (let ((all (fold-packages
296 (lambda (package result)
297 (if (package-replacement package)
299 (package-replacement package)
301 (cons package result)))
303 (job (lambda (package)
304 (package->job store package
306 (append (filter-map job all)
307 (qemu-jobs store system)
308 (system-test-jobs store system)
309 (tarball-jobs store system)
310 (cross-jobs system))))
312 ;; Build core packages only.
313 (append (map (lambda (package)
314 (package-job store (job-name package)
317 (cross-jobs system)))
319 (error "unknown subset" subset))))
320 %hydra-supported-systems)))