1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 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/>.
19 (define-module (build-self)
22 #:use-module (srfi srfi-1)
27 ;;; When loaded, this module returns a monadic procedure of at least one
28 ;;; argument: the source tree to build. It returns a derivation that
31 ;;; This file uses modules provided by the already-installed Guix. Those
32 ;;; modules may be arbitrarily old compared to the version we want to
33 ;;; build. Because of that, it must rely on the smallest set of features
34 ;;; that are likely to be provided by the (guix) and (gnu) modules, and by
35 ;;; Guile itself, forever and ever.
40 ;; The dependencies. Don't refer explicitly to the variables because they
41 ;; could be renamed or shuffled around in modules over time. Conversely,
42 ;; 'find-best-packages-by-name' is expected to always have the same semantics.
45 (first (find-best-packages-by-name "libgcrypt" #f)))
48 (first (find-best-packages-by-name "guile-json" #f)))
52 ;; The actual build procedure.
54 (define (top-source-directory)
55 "Return the name of the top-level directory of this source tree."
56 (and=> (assoc-ref (current-source-location) 'filename)
58 (string-append (dirname file) "/.."))))
60 ;; The procedure below is our return value.
61 (define* (build source #:key verbose?
64 "Return a derivation that unpacks SOURCE into STORE and compiles Scheme
68 (use-modules (guix build pull))
70 (let ((json (string-append #$guile-json "/share/guile/site/2.0")))
71 (set! %load-path (cons json %load-path))
72 (set! %load-compiled-path (cons json %load-compiled-path)))
74 (build-guix #$output #$source
76 ;; XXX: This is not perfect, enabling VERBOSE? means
77 ;; building a different derivation.
78 #:debug-port (if #$verbose?
80 (%make-void-port "w"))
81 #:gcrypt #$libgcrypt)))
83 (gexp->derivation "guix-latest" builder
84 #:modules '((guix build pull)
87 ;; Arrange so that our own (guix build …) modules are
89 #:module-path (list (top-source-directory))))
91 ;; This file is loaded by 'guix pull'; return it the build procedure.
95 ;; eval: (put 'with-load-path 'scheme-indent-function 1)
98 ;;; build-self.scm ends here