hydra: Add "powerpc-linux-gnu" as a cross-compilation target.
[jackhill/guix/guix.git] / build-aux / hydra / gnu-system.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
9410a5aa 2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
8c0e5b1e 3;;;
233e7676 4;;; This file is part of GNU Guix.
8c0e5b1e 5;;;
233e7676 6;;; GNU Guix is free software; you can redistribute it and/or modify it
8c0e5b1e
LC
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;;;
233e7676 11;;; GNU Guix is distributed in the hope that it will be useful, but
8c0e5b1e
LC
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
233e7676 17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
8c0e5b1e
LC
18
19;;;
20;;; This file defines build jobs for the Hydra continuation integration
21;;; tool.
22;;;
23
0b5aa854
LC
24;; Attempt to use our very own Guix modules.
25(eval-when (compile load eval)
bb90ad83
LC
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
0b5aa854
LC
32 (and=> (assoc-ref (current-source-location) 'filename)
33 (lambda (file)
f3211ef3 34 (let ((dir (string-append (dirname file) "/../..")))
0b5aa854
LC
35 (format (current-error-port) "prepending ~s to the load path~%"
36 dir)
37 (set! %load-path (cons dir %load-path))))))
38
731b9962
LC
39(use-modules (guix config)
40 (guix store)
49c4fd2a 41 (guix grafts)
8c0e5b1e 42 (guix packages)
97d010b7 43 (guix derivations)
731b9962
LC
44 (guix monads)
45 ((guix licenses) #:select (gpl3+))
dce3a40b 46 ((guix utils) #:select (%current-system))
731b9962 47 ((guix scripts system) #:select (read-operating-system))
59a43334 48 (gnu packages)
d452b595 49 (gnu packages gcc)
1ffa7090 50 (gnu packages base)
923fbae1 51 (gnu packages gawk)
1ffa7090 52 (gnu packages guile)
aa289a3e 53 (gnu packages gettext)
dfb74e50 54 (gnu packages compression)
929c0f69
LC
55 (gnu packages multiprecision)
56 (gnu packages make-bootstrap)
9e9cb0c7 57 (gnu packages commencement)
b6075935 58 (gnu packages package-management)
731b9962
LC
59 (gnu system)
60 (gnu system vm)
10d86d54 61 (gnu system install)
e702e26a 62 (gnu tests)
bdd7eb27 63 (srfi srfi-1)
dce3a40b 64 (srfi srfi-26)
8c0e5b1e
LC
65 (ice-9 match))
66
dce3a40b
LC
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))
71
929c0f69
LC
72(define* (package->alist store package system
73 #:optional (package-derivation package-derivation))
8c0e5b1e 74 "Convert PACKAGE to an alist suitable for Hydra."
9c3bb4c5
LC
75 (parameterize ((%graft? #f))
76 `((derivation . ,(derivation-file-name
77 (package-derivation store package system
78 #:graft? #f)))
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)
85 'max-silent-time)
86 3600)) ;1 hour by default
87 (timeout . ,(or (assoc-ref (package-properties package) 'timeout)
88 72000))))) ;20 hours by default
8c0e5b1e
LC
89
90(define (package-job store job-name package system)
91 "Return a job called JOB-NAME that builds PACKAGE on SYSTEM."
195e81aa
LC
92 (let ((job-name (symbol-append job-name (string->symbol ".")
93 (string->symbol system))))
94 `(,job-name . ,(cut package->alist store package system))))
8c0e5b1e 95
929c0f69
LC
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
98SYSTEM."
195e81aa
LC
99 `(,(symbol-append (string->symbol target) (string->symbol ".") job-name
100 (string->symbol ".") (string->symbol system)) .
929c0f69 101 ,(cute package->alist store package system
9c960731
LC
102 (lambda* (store package system #:key graft?)
103 (package-cross-derivation store package target system
104 #:graft? graft?)))))
929c0f69 105
6bf25b7b 106(define %core-packages
707c8b2c
LC
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
109 ;; chain.)
629f4d2e 110 (list gcc-4.8 gcc-4.9 gcc-5 glibc binutils
17315967 111 gmp mpfr mpc coreutils findutils diffutils patch sed grep
dfb74e50 112 gawk gnu-gettext hello guile-2.0 zlib gzip xz
9306d350
LC
113 %bootstrap-binaries-tarball
114 %binutils-bootstrap-tarball
115 %glibc-bootstrap-tarball
116 %gcc-bootstrap-tarball
58ab9f9b
LC
117 %guile-bootstrap-tarball
118 %bootstrap-tarballs))
929c0f69 119
6bf25b7b
LC
120(define %packages-to-cross-build
121 %core-packages)
122
929c0f69 123(define %cross-targets
58ab9f9b 124 '("mips64el-linux-gnu"
6ef6246c 125 "mips64el-linux-gnuabi64"
9410a5aa
LC
126 "arm-linux-gnueabihf"
127 "powerpc-linux-gnu"))
929c0f69 128
10d86d54
LC
129(define (demo-os)
130 "Return the \"demo\" 'operating-system' structure."
131 (let* ((dir (dirname (assoc-ref (current-source-location) 'filename)))
132 (file (string-append dir "/demo-os.scm")))
133 (read-operating-system file)))
134
e702e26a
LC
135(define %guixsd-supported-systems
136 '("x86_64-linux" "i686-linux"))
137
731b9962
LC
138(define (qemu-jobs store system)
139 "Return a list of jobs that build QEMU images for SYSTEM."
140 (define (->alist drv)
0ec6237b 141 `((derivation . ,(derivation-file-name drv))
731b9962
LC
142 (description . "Stand-alone QEMU image of the GNU system")
143 (long-description . "This is a demo stand-alone QEMU image of the GNU
144system.")
145 (license . ,gpl3+)
146 (home-page . ,%guix-home-page-url)
147 (maintainers . ("bug-guix@gnu.org"))))
148
149 (define (->job name drv)
150 (let ((name (symbol-append name (string->symbol ".")
151 (string->symbol system))))
9c3bb4c5
LC
152 `(,name . ,(lambda ()
153 (parameterize ((%graft? #f))
154 (->alist drv))))))
731b9962 155
10d86d54
LC
156 (define MiB
157 (expt 2 20))
158
e702e26a 159 (if (member system %guixsd-supported-systems)
10d86d54
LC
160 (list (->job 'qemu-image
161 (run-with-store store
e87f0591
LC
162 (mbegin %store-monad
163 (set-guile-for-build (default-guile))
164 (system-qemu-image (demo-os)
165 #:disk-image-size
166 (* 1400 MiB))))) ; 1.4 GiB
10d86d54
LC
167 (->job 'usb-image
168 (run-with-store store
e87f0591
LC
169 (mbegin %store-monad
170 (set-guile-for-build (default-guile))
171 (system-disk-image installation-os
172 #:disk-image-size
622b2304 173 (* 1024 MiB))))))
731b9962
LC
174 '()))
175
e702e26a
LC
176(define (system-test-jobs store system)
177 "Return a list of jobs for the system tests."
ab23fb83
LC
178 (define (test->thunk test)
179 (lambda ()
180 (define drv
181 (run-with-store store
182 (mbegin %store-monad
183 (set-current-system system)
184 (set-grafting #f)
185 (set-guile-for-build (default-guile))
186 (system-test-value test))))
187
188 `((derivation . ,(derivation-file-name drv))
189 (description . ,(format #f "GuixSD '~a' system test"
190 (system-test-name test)))
191 (long-description . ,(system-test-description test))
192 (license . ,gpl3+)
193 (home-page . ,%guix-home-page-url)
194 (maintainers . ("bug-guix@gnu.org")))))
195
e702e26a
LC
196 (define (->job test)
197 (let ((name (string->symbol
198 (string-append "test." (system-test-name test)
199 "." system))))
ab23fb83 200 (cons name (test->thunk test))))
e702e26a
LC
201
202 (if (member system %guixsd-supported-systems)
203 (map ->job (all-system-tests))
204 '()))
205
b6075935
LC
206(define (tarball-jobs store system)
207 "Return Hydra jobs to build the self-contained Guix binary tarball."
208 (define (->alist drv)
209 `((derivation . ,(derivation-file-name drv))
210 (description . "Stand-alone binary Guix tarball")
211 (long-description . "This is a tarball containing binaries of Guix and
212all its dependencies, and ready to be installed on non-GuixSD distributions.")
213 (license . ,gpl3+)
214 (home-page . ,%guix-home-page-url)
215 (maintainers . ("bug-guix@gnu.org"))))
216
217 (define (->job name drv)
218 (let ((name (symbol-append name (string->symbol ".")
219 (string->symbol system))))
9c3bb4c5
LC
220 `(,name . ,(lambda ()
221 (parameterize ((%graft? #f))
222 (->alist drv))))))
b6075935
LC
223
224 ;; XXX: Add a job for the stable Guix?
225 (list (->job 'binary-tarball
226 (run-with-store store
227 (mbegin %store-monad
228 (set-guile-for-build (default-guile))
229 (self-contained-tarball))
230 #:system system))))
231
4e097f86
LC
232(define job-name
233 ;; Return the name of a package's job.
234 (compose string->symbol package-full-name))
235
236(define package->job
237 (let ((base-packages
238 (delete-duplicates
239 (append-map (match-lambda
240 ((_ package _ ...)
241 (match (package-transitive-inputs package)
242 (((_ inputs _ ...) ...)
243 inputs))))
244 %final-inputs))))
245 (lambda (store package system)
246 "Return a job for PACKAGE on SYSTEM, or #f if this combination is not
247valid."
248 (cond ((member package base-packages)
249 #f)
bbceb0ef 250 ((supported-package? package system)
4e097f86
LC
251 (package-job store (job-name package) package system))
252 (else
253 #f)))))
254
255\f
256;;;
257;;; Hydra entry point.
258;;;
259
8c0e5b1e
LC
260(define (hydra-jobs store arguments)
261 "Return Hydra jobs."
6bf25b7b
LC
262 (define subset
263 (match (assoc-ref arguments 'subset)
264 ("core" 'core) ; only build core packages
265 (_ 'all))) ; build everything
266
77bed842 267 (define (cross-jobs system)
e7958902 268 (define (from-32-to-64? target)
eb55e28c
MW
269 ;; Return true if SYSTEM is 32-bit and TARGET is 64-bit. This hack
270 ;; prevents known-to-fail cross-builds from i686-linux or armhf-linux to
e7958902 271 ;; mips64el-linux-gnuabi64.
eb55e28c
MW
272 (and (or (string-prefix? "i686-" system)
273 (string-prefix? "armhf-" system))
e7958902
LC
274 (string-suffix? "64" target)))
275
411fc81d
LC
276 (define (same? target)
277 ;; Return true if SYSTEM and TARGET are the same thing. This is so we
278 ;; don't try to cross-compile to 'mips64el-linux-gnu' from
279 ;; 'mips64el-linux'.
280 (string-contains target system))
281
282 (define (either proc1 proc2)
283 (lambda (x)
284 (or (proc1 x) (proc2 x))))
285
929c0f69
LC
286 (append-map (lambda (target)
287 (map (lambda (package)
288 (package-cross-job store (job-name package)
289 package target system))
290 %packages-to-cross-build))
411fc81d 291 (remove (either from-32-to-64? same?) %cross-targets)))
929c0f69 292
49c4fd2a
LC
293 ;; Turn off grafts. Grafting is meant to happen on the user's machines.
294 (parameterize ((%graft? #f))
295 ;; Return one job for each package, except bootstrap packages.
296 (append-map (lambda (system)
297 (case subset
298 ((all)
299 ;; Build everything, including replacements.
300 (let ((all (fold-packages
301 (lambda (package result)
302 (if (package-replacement package)
303 (cons* package
304 (package-replacement package)
305 result)
306 (cons package result)))
307 '()))
308 (job (lambda (package)
309 (package->job store package
310 system))))
311 (append (filter-map job all)
312 (qemu-jobs store system)
e702e26a 313 (system-test-jobs store system)
49c4fd2a
LC
314 (tarball-jobs store system)
315 (cross-jobs system))))
316 ((core)
317 ;; Build core packages only.
318 (append (map (lambda (package)
319 (package-job store (job-name package)
320 package system))
321 %core-packages)
322 (cross-jobs system)))
323 (else
324 (error "unknown subset" subset))))
325 %hydra-supported-systems)))