gnu: guile-2.0: support mingw.
[jackhill/guix/guix.git] / build-aux / hydra / gnu-system.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
af467613 2;;; Copyright © 2012, 2013, 2014, 2015, 2016 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
LC
125 "mips64el-linux-gnuabi64"
126 "arm-linux-gnueabihf"))
929c0f69 127
10d86d54
LC
128(define (demo-os)
129 "Return the \"demo\" 'operating-system' structure."
130 (let* ((dir (dirname (assoc-ref (current-source-location) 'filename)))
131 (file (string-append dir "/demo-os.scm")))
132 (read-operating-system file)))
133
e702e26a
LC
134(define %guixsd-supported-systems
135 '("x86_64-linux" "i686-linux"))
136
731b9962
LC
137(define (qemu-jobs store system)
138 "Return a list of jobs that build QEMU images for SYSTEM."
139 (define (->alist drv)
0ec6237b 140 `((derivation . ,(derivation-file-name drv))
731b9962
LC
141 (description . "Stand-alone QEMU image of the GNU system")
142 (long-description . "This is a demo stand-alone QEMU image of the GNU
143system.")
144 (license . ,gpl3+)
145 (home-page . ,%guix-home-page-url)
146 (maintainers . ("bug-guix@gnu.org"))))
147
148 (define (->job name drv)
149 (let ((name (symbol-append name (string->symbol ".")
150 (string->symbol system))))
9c3bb4c5
LC
151 `(,name . ,(lambda ()
152 (parameterize ((%graft? #f))
153 (->alist drv))))))
731b9962 154
10d86d54
LC
155 (define MiB
156 (expt 2 20))
157
e702e26a 158 (if (member system %guixsd-supported-systems)
10d86d54
LC
159 (list (->job 'qemu-image
160 (run-with-store store
e87f0591
LC
161 (mbegin %store-monad
162 (set-guile-for-build (default-guile))
163 (system-qemu-image (demo-os)
164 #:disk-image-size
165 (* 1400 MiB))))) ; 1.4 GiB
10d86d54
LC
166 (->job 'usb-image
167 (run-with-store store
e87f0591
LC
168 (mbegin %store-monad
169 (set-guile-for-build (default-guile))
170 (system-disk-image installation-os
171 #:disk-image-size
622b2304 172 (* 1024 MiB))))))
731b9962
LC
173 '()))
174
e702e26a
LC
175(define (system-test-jobs store system)
176 "Return a list of jobs for the system tests."
ab23fb83
LC
177 (define (test->thunk test)
178 (lambda ()
179 (define drv
180 (run-with-store store
181 (mbegin %store-monad
182 (set-current-system system)
183 (set-grafting #f)
184 (set-guile-for-build (default-guile))
185 (system-test-value test))))
186
187 `((derivation . ,(derivation-file-name drv))
188 (description . ,(format #f "GuixSD '~a' system test"
189 (system-test-name test)))
190 (long-description . ,(system-test-description test))
191 (license . ,gpl3+)
192 (home-page . ,%guix-home-page-url)
193 (maintainers . ("bug-guix@gnu.org")))))
194
e702e26a
LC
195 (define (->job test)
196 (let ((name (string->symbol
197 (string-append "test." (system-test-name test)
198 "." system))))
ab23fb83 199 (cons name (test->thunk test))))
e702e26a
LC
200
201 (if (member system %guixsd-supported-systems)
202 (map ->job (all-system-tests))
203 '()))
204
b6075935
LC
205(define (tarball-jobs store system)
206 "Return Hydra jobs to build the self-contained Guix binary tarball."
207 (define (->alist drv)
208 `((derivation . ,(derivation-file-name drv))
209 (description . "Stand-alone binary Guix tarball")
210 (long-description . "This is a tarball containing binaries of Guix and
211all its dependencies, and ready to be installed on non-GuixSD distributions.")
212 (license . ,gpl3+)
213 (home-page . ,%guix-home-page-url)
214 (maintainers . ("bug-guix@gnu.org"))))
215
216 (define (->job name drv)
217 (let ((name (symbol-append name (string->symbol ".")
218 (string->symbol system))))
9c3bb4c5
LC
219 `(,name . ,(lambda ()
220 (parameterize ((%graft? #f))
221 (->alist drv))))))
b6075935
LC
222
223 ;; XXX: Add a job for the stable Guix?
224 (list (->job 'binary-tarball
225 (run-with-store store
226 (mbegin %store-monad
227 (set-guile-for-build (default-guile))
228 (self-contained-tarball))
229 #:system system))))
230
4e097f86
LC
231(define job-name
232 ;; Return the name of a package's job.
233 (compose string->symbol package-full-name))
234
235(define package->job
236 (let ((base-packages
237 (delete-duplicates
238 (append-map (match-lambda
239 ((_ package _ ...)
240 (match (package-transitive-inputs package)
241 (((_ inputs _ ...) ...)
242 inputs))))
243 %final-inputs))))
244 (lambda (store package system)
245 "Return a job for PACKAGE on SYSTEM, or #f if this combination is not
246valid."
247 (cond ((member package base-packages)
248 #f)
bbceb0ef 249 ((supported-package? package system)
4e097f86
LC
250 (package-job store (job-name package) package system))
251 (else
252 #f)))))
253
254\f
255;;;
256;;; Hydra entry point.
257;;;
258
8c0e5b1e
LC
259(define (hydra-jobs store arguments)
260 "Return Hydra jobs."
6bf25b7b
LC
261 (define subset
262 (match (assoc-ref arguments 'subset)
263 ("core" 'core) ; only build core packages
264 (_ 'all))) ; build everything
265
77bed842 266 (define (cross-jobs system)
e7958902 267 (define (from-32-to-64? target)
eb55e28c
MW
268 ;; Return true if SYSTEM is 32-bit and TARGET is 64-bit. This hack
269 ;; prevents known-to-fail cross-builds from i686-linux or armhf-linux to
e7958902 270 ;; mips64el-linux-gnuabi64.
eb55e28c
MW
271 (and (or (string-prefix? "i686-" system)
272 (string-prefix? "armhf-" system))
e7958902
LC
273 (string-suffix? "64" target)))
274
411fc81d
LC
275 (define (same? target)
276 ;; Return true if SYSTEM and TARGET are the same thing. This is so we
277 ;; don't try to cross-compile to 'mips64el-linux-gnu' from
278 ;; 'mips64el-linux'.
279 (string-contains target system))
280
281 (define (either proc1 proc2)
282 (lambda (x)
283 (or (proc1 x) (proc2 x))))
284
929c0f69
LC
285 (append-map (lambda (target)
286 (map (lambda (package)
287 (package-cross-job store (job-name package)
288 package target system))
289 %packages-to-cross-build))
411fc81d 290 (remove (either from-32-to-64? same?) %cross-targets)))
929c0f69 291
49c4fd2a
LC
292 ;; Turn off grafts. Grafting is meant to happen on the user's machines.
293 (parameterize ((%graft? #f))
294 ;; Return one job for each package, except bootstrap packages.
295 (append-map (lambda (system)
296 (case subset
297 ((all)
298 ;; Build everything, including replacements.
299 (let ((all (fold-packages
300 (lambda (package result)
301 (if (package-replacement package)
302 (cons* package
303 (package-replacement package)
304 result)
305 (cons package result)))
306 '()))
307 (job (lambda (package)
308 (package->job store package
309 system))))
310 (append (filter-map job all)
311 (qemu-jobs store system)
e702e26a 312 (system-test-jobs store system)
49c4fd2a
LC
313 (tarball-jobs store system)
314 (cross-jobs system))))
315 ((core)
316 ;; Build core packages only.
317 (append (map (lambda (package)
318 (package-job store (job-name package)
319 package system))
320 %core-packages)
321 (cross-jobs system)))
322 (else
323 (error "unknown subset" subset))))
324 %hydra-supported-systems)))