Commit | Line | Data |
---|---|---|
dadee6cd | 1 | #!@GUILE@ --no-auto-compile |
e49951eb MW |
2 | -*- scheme -*- |
3 | !# | |
4 | ;;; GNU Guix --- Functional package management for GNU | |
5 | ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org> | |
6 | ;;; | |
7 | ;;; This file is part of GNU Guix. | |
8 | ;;; | |
9 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
10 | ;;; under the terms of the GNU General Public License as published by | |
11 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
12 | ;;; your option) any later version. | |
13 | ;;; | |
14 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
15 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | ;;; GNU General Public License for more details. | |
18 | ;;; | |
19 | ;;; You should have received a copy of the GNU General Public License | |
20 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
21 | ||
22 | ;; IMPORTANT: We must avoid loading any modules from Guix here, | |
23 | ;; because we need to adjust the guile load paths first. | |
24 | ;; It's okay to import modules from core Guile though. | |
f651b477 LC |
25 | (use-modules (ice-9 regex) |
26 | (srfi srfi-26)) | |
e49951eb MW |
27 | |
28 | (let () | |
29 | (define-syntax-rule (push! elt v) (set! v (cons elt v))) | |
30 | ||
31 | (define config-lookup | |
32 | (let ((config '(("prefix" . "@prefix@") | |
9437fd73 | 33 | ("exec_prefix" . "@exec_prefix@") |
e49951eb | 34 | ("datarootdir" . "@datarootdir@") |
39e9f95d | 35 | ("guilemoduledir" . "@guilemoduledir@") |
9437fd73 | 36 | ("guileobjectdir" . "@guileobjectdir@") |
39e9f95d | 37 | ("localedir" . "@localedir@"))) |
9437fd73 | 38 | (var-ref-regexp (make-regexp "\\$\\{([a-z_]+)\\}"))) |
e49951eb MW |
39 | (define (expand-var-ref match) |
40 | (lookup (match:substring match 1))) | |
41 | (define (expand str) | |
42 | (regexp-substitute/global #f var-ref-regexp str | |
43 | 'pre expand-var-ref 'post)) | |
44 | (define (lookup name) | |
45 | (expand (assoc-ref config name))) | |
46 | lookup)) | |
47 | ||
48 | (define (maybe-augment-load-paths!) | |
49 | (unless (getenv "GUIX_UNINSTALLED") | |
9437fd73 LC |
50 | (let ((module-dir (config-lookup "guilemoduledir")) |
51 | (object-dir (config-lookup "guileobjectdir"))) | |
e49951eb | 52 | (push! module-dir %load-path) |
9437fd73 | 53 | (push! object-dir %load-compiled-path)) |
f651b477 LC |
54 | (let ((updates-dir (and=> (or (getenv "XDG_CONFIG_HOME") |
55 | (and=> (getenv "HOME") | |
56 | (cut string-append <> "/.config"))) | |
57 | (cut string-append <> "/guix/latest")))) | |
525ca3e9 | 58 | (when (and updates-dir (file-exists? updates-dir)) |
9437fd73 LC |
59 | ;; XXX: Currently 'guix pull' puts both .scm and .go files in |
60 | ;; UPDATES-DIR. | |
f651b477 LC |
61 | (push! updates-dir %load-path) |
62 | (push! updates-dir %load-compiled-path))))) | |
e49951eb MW |
63 | |
64 | (define (run-guix-main) | |
65 | (let ((guix-main (module-ref (resolve-interface '(guix ui)) | |
66 | 'guix-main))) | |
39e9f95d | 67 | (bindtextdomain "guix" (config-lookup "localedir")) |
243cea24 | 68 | (bindtextdomain "guix-packages" (config-lookup "localedir")) |
e49951eb MW |
69 | (apply guix-main (command-line)))) |
70 | ||
71 | (maybe-augment-load-paths!) | |
7cffaeb6 LC |
72 | |
73 | ;; XXX: It would be more convenient to change it to: | |
74 | ;; (exit (run-guix-main)) | |
75 | ;; but since the 'guix' command is not updated by 'guix pull', we cannot | |
76 | ;; really do it now. | |
e49951eb | 77 | (run-guix-main)) |