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@") | |
33 | ("datarootdir" . "@datarootdir@") | |
39e9f95d LC |
34 | ("guilemoduledir" . "@guilemoduledir@") |
35 | ("localedir" . "@localedir@"))) | |
e49951eb MW |
36 | (var-ref-regexp (make-regexp "\\$\\{([a-z]+)\\}"))) |
37 | (define (expand-var-ref match) | |
38 | (lookup (match:substring match 1))) | |
39 | (define (expand str) | |
40 | (regexp-substitute/global #f var-ref-regexp str | |
41 | 'pre expand-var-ref 'post)) | |
42 | (define (lookup name) | |
43 | (expand (assoc-ref config name))) | |
44 | lookup)) | |
45 | ||
46 | (define (maybe-augment-load-paths!) | |
47 | (unless (getenv "GUIX_UNINSTALLED") | |
48 | (let ((module-dir (config-lookup "guilemoduledir"))) | |
49 | (push! module-dir %load-path) | |
f651b477 LC |
50 | (push! module-dir %load-compiled-path)) |
51 | (let ((updates-dir (and=> (or (getenv "XDG_CONFIG_HOME") | |
52 | (and=> (getenv "HOME") | |
53 | (cut string-append <> "/.config"))) | |
54 | (cut string-append <> "/guix/latest")))) | |
525ca3e9 | 55 | (when (and updates-dir (file-exists? updates-dir)) |
f651b477 LC |
56 | (push! updates-dir %load-path) |
57 | (push! updates-dir %load-compiled-path))))) | |
e49951eb MW |
58 | |
59 | (define (run-guix-main) | |
60 | (let ((guix-main (module-ref (resolve-interface '(guix ui)) | |
61 | 'guix-main))) | |
39e9f95d | 62 | (bindtextdomain "guix" (config-lookup "localedir")) |
243cea24 | 63 | (bindtextdomain "guix-packages" (config-lookup "localedir")) |
e49951eb MW |
64 | (apply guix-main (command-line)))) |
65 | ||
66 | (maybe-augment-load-paths!) | |
67 | (run-guix-main)) |