1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016 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 commencement)
58 (gnu packages package-management)
67 ;; XXX: Debugging hack: since `hydra-eval-guile-jobs' redirects the output
68 ;; port to the bit bucket, let us write to the error port instead.
69 (setvbuf (current-error-port) _IOLBF)
70 (set-current-output-port (current-error-port))
72 (define* (package->alist store package system
73 #:optional (package-derivation package-derivation))
74 "Convert PACKAGE to an alist suitable for Hydra."
75 (parameterize ((%graft? #f))
76 `((derivation . ,(derivation-file-name
77 (package-derivation store package system
79 (description . ,(package-synopsis package))
80 (long-description . ,(package-description package))
81 (license . ,(package-license package))
82 (home-page . ,(package-home-page package))
83 (maintainers . ("bug-guix@gnu.org"))
84 (max-silent-time . ,(or (assoc-ref (package-properties package)
86 3600)) ;1 hour by default
87 (timeout . ,(or (assoc-ref (package-properties package) 'timeout)
88 72000))))) ;20 hours by default
90 (define (package-job store job-name package system)
91 "Return a job called JOB-NAME that builds PACKAGE on SYSTEM."
92 (let ((job-name (symbol-append job-name (string->symbol ".")
93 (string->symbol system))))
94 `(,job-name . ,(cut package->alist store package system))))
96 (define (package-cross-job store job-name package target system)
97 "Return a job called TARGET.JOB-NAME that cross-builds PACKAGE for TARGET on
99 `(,(symbol-append (string->symbol target) (string->symbol ".") job-name
100 (string->symbol ".") (string->symbol system)) .
101 ,(cute package->alist store package system
102 (lambda* (store package system #:key graft?)
103 (package-cross-derivation store package target system
106 (define %core-packages
107 ;; Note: Don't put the '-final' package variants because (1) that's
108 ;; implicit, and (2) they cannot be cross-built (due to the explicit input
110 (list gcc-4.8 gcc-4.9 gcc-5 glibc binutils
111 gmp mpfr mpc coreutils findutils diffutils patch sed grep
112 gawk gnu-gettext hello guile-2.0 zlib gzip xz
113 %bootstrap-binaries-tarball
114 %binutils-bootstrap-tarball
115 %glibc-bootstrap-tarball
116 %gcc-bootstrap-tarball
117 %guile-bootstrap-tarball
118 %bootstrap-tarballs))
120 (define %packages-to-cross-build
123 (define %cross-targets
124 '("mips64el-linux-gnu"
125 "mips64el-linux-gnuabi64"))
128 "Return the \"demo\" 'operating-system' structure."
129 (let* ((dir (dirname (assoc-ref (current-source-location) 'filename)))
130 (file (string-append dir "/demo-os.scm")))
131 (read-operating-system file)))
133 (define %guixsd-supported-systems
134 '("x86_64-linux" "i686-linux"))
136 (define (qemu-jobs store system)
137 "Return a list of jobs that build QEMU images for SYSTEM."
138 (define (->alist drv)
139 `((derivation . ,(derivation-file-name drv))
140 (description . "Stand-alone QEMU image of the GNU system")
141 (long-description . "This is a demo stand-alone QEMU image of the GNU
144 (home-page . ,%guix-home-page-url)
145 (maintainers . ("bug-guix@gnu.org"))))
147 (define (->job name drv)
148 (let ((name (symbol-append name (string->symbol ".")
149 (string->symbol system))))
150 `(,name . ,(lambda ()
151 (parameterize ((%graft? #f))
157 (if (member system %guixsd-supported-systems)
158 (list (->job 'qemu-image
159 (run-with-store store
161 (set-guile-for-build (default-guile))
162 (system-qemu-image (demo-os)
164 (* 1400 MiB))))) ; 1.4 GiB
166 (run-with-store store
168 (set-guile-for-build (default-guile))
169 (system-disk-image installation-os
174 (define (system-test-jobs store system)
175 "Return a list of jobs for the system tests."
176 (define (test->thunk test)
179 (run-with-store store
181 (set-current-system system)
183 (set-guile-for-build (default-guile))
184 (system-test-value test))))
186 `((derivation . ,(derivation-file-name drv))
187 (description . ,(format #f "GuixSD '~a' system test"
188 (system-test-name test)))
189 (long-description . ,(system-test-description test))
191 (home-page . ,%guix-home-page-url)
192 (maintainers . ("bug-guix@gnu.org")))))
195 (let ((name (string->symbol
196 (string-append "test." (system-test-name test)
198 (cons name (test->thunk test))))
200 (if (member system %guixsd-supported-systems)
201 (map ->job (all-system-tests))
204 (define (tarball-jobs store system)
205 "Return Hydra jobs to build the self-contained Guix binary tarball."
206 (define (->alist drv)
207 `((derivation . ,(derivation-file-name drv))
208 (description . "Stand-alone binary Guix tarball")
209 (long-description . "This is a tarball containing binaries of Guix and
210 all its dependencies, and ready to be installed on non-GuixSD distributions.")
212 (home-page . ,%guix-home-page-url)
213 (maintainers . ("bug-guix@gnu.org"))))
215 (define (->job name drv)
216 (let ((name (symbol-append name (string->symbol ".")
217 (string->symbol system))))
218 `(,name . ,(lambda ()
219 (parameterize ((%graft? #f))
222 ;; XXX: Add a job for the stable Guix?
223 (list (->job 'binary-tarball
224 (run-with-store store
226 (set-guile-for-build (default-guile))
227 (self-contained-tarball))
231 ;; Return the name of a package's job.
232 (compose string->symbol package-full-name))
237 (append-map (match-lambda
239 (match (package-transitive-inputs package)
240 (((_ inputs _ ...) ...)
243 (lambda (store package system)
244 "Return a job for PACKAGE on SYSTEM, or #f if this combination is not
246 (cond ((member package base-packages)
248 ((supported-package? package system)
249 (package-job store (job-name package) package system))
255 ;;; Hydra entry point.
258 (define (hydra-jobs store arguments)
261 (match (assoc-ref arguments 'subset)
262 ("core" 'core) ; only build core packages
263 (_ 'all))) ; build everything
265 (define (cross-jobs system)
266 (define (from-32-to-64? target)
267 ;; Return true if SYSTEM is 32-bit and TARGET is 64-bit. This hack
268 ;; prevents known-to-fail cross-builds from i686-linux or armhf-linux to
269 ;; mips64el-linux-gnuabi64.
270 (and (or (string-prefix? "i686-" system)
271 (string-prefix? "armhf-" system))
272 (string-suffix? "64" target)))
274 (define (same? target)
275 ;; Return true if SYSTEM and TARGET are the same thing. This is so we
276 ;; don't try to cross-compile to 'mips64el-linux-gnu' from
278 (string-contains target system))
280 (define (either proc1 proc2)
282 (or (proc1 x) (proc2 x))))
284 (append-map (lambda (target)
285 (map (lambda (package)
286 (package-cross-job store (job-name package)
287 package target system))
288 %packages-to-cross-build))
289 (remove (either from-32-to-64? same?) %cross-targets)))
291 ;; Turn off grafts. Grafting is meant to happen on the user's machines.
292 (parameterize ((%graft? #f))
293 ;; Return one job for each package, except bootstrap packages.
294 (append-map (lambda (system)
297 ;; Build everything, including replacements.
298 (let ((all (fold-packages
299 (lambda (package result)
300 (if (package-replacement package)
302 (package-replacement package)
304 (cons package result)))
306 (job (lambda (package)
307 (package->job store package
309 (append (filter-map job all)
310 (qemu-jobs store system)
311 (system-test-jobs store system)
312 (tarball-jobs store system)
313 (cross-jobs system))))
315 ;; Build core packages only.
316 (append (map (lambda (package)
317 (package-job store (job-name package)
320 (cross-jobs system)))
322 (error "unknown subset" subset))))
323 %hydra-supported-systems)))