aboutsummaryrefslogtreecommitdiff
path: root/build-aux/compile-as-derivation.scm
blob: d945a8c79c6670870bccc6de3cfffc4d50880cce (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

;; Build Guix using Guix.

(use-modules (srfi srfi-26))

;; Add ~/.config/guix/current to the search path.
(eval-when (expand load eval)
  (and=> (or (getenv "XDG_CONFIG_HOME")
             (and=> (getenv "HOME")
                    (cut string-append <> "/.config/guix/current")))
         (lambda (current)
           (set! %load-path
             (cons (string-append current "/share/guile/site/"
                                  (effective-version))
                   %load-path))
           (set! %load-compiled-path
             (cons (string-append current "/lib/guile/" (effective-version)
                                  "/site-ccache")
                   %load-compiled-path)))))

(use-modules (guix) (guix ui)
             (guix git-download)
             (ice-9 match))

(match (command-line)
  ((program source)
   (with-error-handling
     (with-store store
       (let* ((script (string-append source "/build-aux/build-self.scm"))
              (build  (primitive-load script))
              (git?   (git-predicate source)))
         (run-with-store store
           ;; TODO: Extract #:version and #:commit using Guile-Git.
           (mlet* %store-monad ((source (interned-file source "guix-source"
                                                       #:select? git?
                                                       #:recursive? #t))
                                (drv    (build source #:pull-version 1)))
             (mbegin %store-monad
               (show-what-to-build* (list drv))
               (built-derivations (list drv))
               (with-monad %store-monad
                 (display (derivation->output-path drv))
                 (newline)
                 (return drv))))))))))
an>Ludovic Courtès 2019-04-26bootstrap: Break automake dependency on generated files....Miguel Ángel Arruga Vivas 2018-11-20.gitignore: Re-add 'authenticate' script....Marius Bakke 2018-06-14Remove 'guix-register' and its traces....Ludovic Courtès 2018-06-12.gitignore: Add doc/stamp-[0-9].Ludovic Courtès 2018-04-19gnu: doc: Allow documentation to be translated....Julien Lepiller 2018-02-13.gitignore: Add guix-daemon SELinux policy....Efraim Flashner 2017-05-13.gitignore: Ignore Emacs auto-save files....ng0 2017-05-08build: Add doc/guix.html to .gitignore....Clément Lassieur 2017-05-04build: Use Gnulib's 'git-version-gen'....Ludovic Courtès 2017-02-27.gitignore: Remove stale entries....Alex Kost 2017-02-10build: Add build-aux/ar-lib to .gitignore....Clément Lassieur 2017-01-13etc: Support indentation of whole files....Ludovic Courtès 2017-01-12etc: Add 'indent-package.el' script....Ludovic Courtès 2016-11-24Add system start-up files for "guix publish"....Hartmut Goebel 2016-11-16daemon: Add "builtin:download" derivation builder....Ludovic Courtès 2016-07-05build: Ignore texi2pdf temporary files....David Craven