897c5c615271293ec2cc05ca46b2b943bd74e5af
[jackhill/guix/guix.git] / guix / build-system / trivial.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
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.
10 ;;;
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.
15 ;;;
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/>.
18
19 (define-module (guix build-system trivial)
20 #:use-module (guix store)
21 #:use-module (guix utils)
22 #:use-module (guix derivations)
23 #:use-module (guix packages)
24 #:use-module (guix build-system)
25 #:use-module (ice-9 match)
26 #:export (trivial-build-system))
27
28 (define (guile-for-build store guile system)
29 (match guile
30 ((? package?)
31 (package-derivation store guile system))
32 (#f ; the default
33 (let* ((distro (resolve-interface '(gnu packages commencement)))
34 (guile (module-ref distro 'guile-final)))
35 (package-derivation store guile system)))))
36
37 (define* (trivial-build store name source inputs
38 #:key
39 outputs guile system builder (modules '())
40 search-paths)
41 "Run build expression BUILDER, an expression, for SYSTEM. SOURCE is
42 ignored."
43 (build-expression->derivation store name builder
44 #:inputs (if source
45 `(("source" ,source) ,@inputs)
46 inputs)
47 #:system system
48 #:outputs outputs
49 #:modules modules
50 #:guile-for-build
51 (guile-for-build store guile system)))
52
53 (define* (trivial-cross-build store name target source inputs native-inputs
54 #:key
55 outputs guile system builder (modules '())
56 search-paths native-search-paths)
57 "Like `trivial-build', but in a cross-compilation context."
58 (build-expression->derivation store name builder
59 #:system system
60 #:inputs
61 (let ((inputs (append native-inputs inputs)))
62 (if source
63 `(("source" ,source) ,@inputs)
64 inputs))
65 #:outputs outputs
66 #:modules modules
67 #:guile-for-build
68 (guile-for-build store guile system)))
69
70 (define trivial-build-system
71 (build-system (name 'trivial)
72 (description
73 "Trivial build system, to run arbitrary Scheme build expressions")
74 (build trivial-build)
75 (cross-build trivial-cross-build)))