gnu: Add vowpal-wabbit.
[guix.git] / build-aux / compile-as-derivation.scm
blob59a84b14151553547943258c57ec3643bd1f7dc3
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 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/>.
19 ;; Build Guix using Guix.
21 (use-modules (srfi srfi-26))
23 ;; Add ~/.config/guix/latest to the search path.
24 (add-to-load-path
25  (and=> (or (getenv "XDG_CONFIG_HOME")
26             (and=> (getenv "HOME")
27                    (cut string-append <> "/.config")))
28         (cute string-append <> "/guix/current/share/guile/site/"
29               (effective-version))))
31 (use-modules (guix) (guix ui)
32              (guix git-download)
33              (ice-9 match))
35 (match (command-line)
36   ((program source)
37    (with-error-handling
38      (with-store store
39        (let* ((script (string-append source "/build-aux/build-self.scm"))
40               (build  (primitive-load script))
41               (git?   (git-predicate source)))
42          (run-with-store store
43            ;; TODO: Extract #:version and #:commit using Guile-Git.
44            (mlet* %store-monad ((source (interned-file source "guix-source"
45                                                        #:select? git?
46                                                        #:recursive? #t))
47                                 (drv    (build source #:pull-version 1)))
48              (mbegin %store-monad
49                (show-what-to-build* (list drv))
50                (built-derivations (list drv))
51                (with-monad %store-monad
52                  (display (derivation->output-path drv))
53                  (newline)
54                  (return drv))))))))))