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)
46 ((guix licenses) #:select (gpl3+))
47 ((guix utils) #:select (%current-system))
48 ((guix scripts system) #:select (read-operating-system))
50 #:select (lookup-compressor self-contained-tarball))
56 (gnu packages gettext)
57 (gnu packages compression)
58 (gnu packages multiprecision)
59 (gnu packages make-bootstrap)
60 (gnu packages package-management)
69 ;; XXX: Debugging hack: since `hydra-eval-guile-jobs' redirects the output
70 ;; port to the bit bucket, let us write to the error port instead.
71 (setvbuf (current-error-port) _IOLBF)
72 (set-current-output-port (current-error-port))
74 (define* (package->alist store package system
75 #:optional (package-derivation package-derivation))
76 "Convert PACKAGE to an alist suitable for Hydra."
77 (parameterize ((%graft? #f))
78 `((derivation . ,(derivation-file-name
79 (package-derivation store package system
81 (description . ,(package-synopsis package))
82 (long-description . ,(package-description package))
83 (license . ,(package-license package))
84 (home-page . ,(package-home-page package))
85 (maintainers . ("bug-guix@gnu.org"))
86 (max-silent-time . ,(or (assoc-ref (package-properties package)
88 3600)) ;1 hour by default
89 (timeout . ,(or (assoc-ref (package-properties package) 'timeout)
90 72000))))) ;20 hours by default
92 (define (package-job store job-name package system)
93 "Return a job called JOB-NAME that builds PACKAGE on SYSTEM."
94 (let ((job-name (symbol-append job-name (string->symbol ".")
95 (string->symbol system))))
96 `(,job-name . ,(cut package->alist store package system))))
98 (define (package-cross-job store job-name package target system)
99 "Return a job called TARGET.JOB-NAME that cross-builds PACKAGE for TARGET on
101 `(,(symbol-append (string->symbol target) (string->symbol ".") job-name
102 (string->symbol ".") (string->symbol system)) .
103 ,(cute package->alist store package system
104 (lambda* (store package system #:key graft?)
105 (package-cross-derivation store package target system
108 (define %core-packages
109 ;; Note: Don't put the '-final' package variants because (1) that's
110 ;; implicit, and (2) they cannot be cross-built (due to the explicit input
112 (list gcc-4.8 gcc-4.9 gcc-5 glibc binutils
113 gmp mpfr mpc coreutils findutils diffutils patch sed grep
114 gawk gnu-gettext hello guile-2.0 guile-2.2 zlib gzip xz
115 %bootstrap-binaries-tarball
116 %binutils-bootstrap-tarball
117 (%glibc-bootstrap-tarball)
118 %gcc-bootstrap-tarball
119 %guile-bootstrap-tarball
120 %bootstrap-tarballs))
122 (define %packages-to-cross-build
125 (define %cross-targets
126 '("mips64el-linux-gnu"
127 "mips64el-linux-gnuabi64"
128 "arm-linux-gnueabihf"
131 "i586-pc-gnu" ;aka. GNU/Hurd
134 (define %guixsd-supported-systems
135 '("x86_64-linux" "i686-linux"))
137 (define (qemu-jobs store system)
138 "Return a list of jobs that build QEMU images for SYSTEM."
139 (define (->alist drv)
140 `((derivation . ,(derivation-file-name drv))
141 (description . "Stand-alone QEMU image of the GNU system")
142 (long-description . "This is a demo stand-alone QEMU image of the GNU
145 (home-page . ,%guix-home-page-url)
146 (maintainers . ("bug-guix@gnu.org"))))
148 (define (->job name drv)
149 (let ((name (symbol-append name (string->symbol ".")
150 (string->symbol system))))
151 `(,name . ,(lambda ()
152 (parameterize ((%graft? #f))
158 (if (member system %guixsd-supported-systems)
159 (list (->job 'usb-image
160 (run-with-store store
162 (set-guile-for-build (default-guile))
163 (system-disk-image installation-os
168 (define (system-test-jobs store system)
169 "Return a list of jobs for the system tests."
170 (define (test->thunk test)
173 (run-with-store store
175 (set-current-system system)
177 (set-guile-for-build (default-guile))
178 (system-test-value test))))
180 `((derivation . ,(derivation-file-name drv))
181 (description . ,(format #f "GuixSD '~a' system test"
182 (system-test-name test)))
183 (long-description . ,(system-test-description test))
185 (home-page . ,%guix-home-page-url)
186 (maintainers . ("bug-guix@gnu.org")))))
189 (let ((name (string->symbol
190 (string-append "test." (system-test-name test)
192 (cons name (test->thunk test))))
194 (if (member system %guixsd-supported-systems)
195 (map ->job (all-system-tests))
198 (define (tarball-jobs store system)
199 "Return Hydra jobs to build the self-contained Guix binary tarball."
200 (define (->alist drv)
201 `((derivation . ,(derivation-file-name drv))
202 (description . "Stand-alone binary Guix tarball")
203 (long-description . "This is a tarball containing binaries of Guix and
204 all its dependencies, and ready to be installed on non-GuixSD distributions.")
206 (home-page . ,%guix-home-page-url)
207 (maintainers . ("bug-guix@gnu.org"))))
209 (define (->job name drv)
210 (let ((name (symbol-append name (string->symbol ".")
211 (string->symbol system))))
212 `(,name . ,(lambda ()
213 (parameterize ((%graft? #f))
216 ;; XXX: Add a job for the stable Guix?
217 (list (->job 'binary-tarball
218 (run-with-store store
220 (set-guile-for-build (default-guile))
221 (>>= (profile-derivation (packages->manifest (list guix)))
223 (self-contained-tarball "guix-binary" profile
226 (lookup-compressor "xz")))))
230 ;; Return the name of a package's job.
231 (compose string->symbol package-full-name))
236 (append-map (match-lambda
238 (match (package-transitive-inputs package)
239 (((_ inputs _ ...) ...)
242 (lambda (store package system)
243 "Return a job for PACKAGE on SYSTEM, or #f if this combination is not
245 (cond ((member package base-packages)
247 ((supported-package? package system)
248 (package-job store (job-name package) package system))
254 ;;; Hydra entry point.
257 (define (hydra-jobs store arguments)
260 (match (assoc-ref arguments 'subset)
261 ("core" 'core) ; only build core packages
262 (_ 'all))) ; build everything
264 (define (cross-jobs system)
265 (define (from-32-to-64? target)
266 ;; Return true if SYSTEM is 32-bit and TARGET is 64-bit. This hack
267 ;; prevents known-to-fail cross-builds from i686-linux or armhf-linux to
268 ;; mips64el-linux-gnuabi64.
269 (and (or (string-prefix? "i686-" system)
270 (string-prefix? "i586-" system)
271 (string-prefix? "armhf-" system))
272 (string-contains target "64"))) ;x86_64, mips64el, aarch64, etc.
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 (or (string-contains target system)
279 (and (string-prefix? "armhf" system) ;armhf-linux
280 (string-prefix? "arm" target)))) ;arm-linux-gnueabihf
282 (define (pointless? target)
283 ;; Return #t if it makes no sense to cross-build to TARGET from SYSTEM.
284 (and (string-contains target "mingw")
285 (not (string=? "x86_64-linux" system))))
287 (define (either proc1 proc2 proc3)
289 (or (proc1 x) (proc2 x) (proc3 x))))
291 (append-map (lambda (target)
292 (map (lambda (package)
293 (package-cross-job store (job-name package)
294 package target system))
295 %packages-to-cross-build))
296 (remove (either from-32-to-64? same? pointless?)
299 ;; Turn off grafts. Grafting is meant to happen on the user's machines.
300 (parameterize ((%graft? #f))
301 ;; Return one job for each package, except bootstrap packages.
302 (append-map (lambda (system)
305 ;; Build everything, including replacements.
306 (let ((all (fold-packages
307 (lambda (package result)
308 (cond ((package-replacement package)
310 (package-replacement package)
312 ((package-superseded package)
313 result) ;don't build it
315 (cons package result))))
317 (job (lambda (package)
318 (package->job store package
320 (append (filter-map job all)
321 (qemu-jobs store system)
322 (system-test-jobs store system)
323 (tarball-jobs store system)
324 (cross-jobs system))))
326 ;; Build core packages only.
327 (append (map (lambda (package)
328 (package-job store (job-name package)
331 (cross-jobs system)))
333 (error "unknown subset" subset))))
334 %hydra-supported-systems)))