diff options
| author | Mathieu Lirzin <mthl@gnu.org> | 2018-01-23 12:52:33 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2018-01-23 15:01:15 +0100 |
| commit | 6f774d481839f87178c5895ac2d661e141f879b8 (patch) | |
| tree | d5fa26bd53d4f4132eab14155b409a7b3f85e878 /scripts/guix.in | |
| parent | 1b5bee004bc2558ecb45877645edb9abb0571591 (diff) | |
guix: Refactor script.
* scripts/guix.in: Remove empty surrounding ‘let’. Define 'main' as the
procedure called when running the script.
(maybe-augment-load-paths!): Rename to ...
(augment-load-paths!): ... this. Use 'and=>' for 'file-exists?'.
(run-guix-main): Rename to ...
(main): ... this. Call 'augment-load-paths!'.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'scripts/guix.in')
| -rw-r--r-- | scripts/guix.in | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/scripts/guix.in b/scripts/guix.in index af50a782bbb..e0f0ae7e068 100644 --- a/scripts/guix.in +++ b/scripts/guix.in | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #!@GUILE@ --no-auto-compile | 1 | #!@GUILE@ \ |
| 2 | --no-auto-compile -e main -s | ||
| 2 | -*- scheme -*- | 3 | -*- scheme -*- |
| 3 | !# | 4 | !# |
| 4 | ;;; GNU Guix --- Functional package management for GNU | 5 | ;;; GNU Guix --- Functional package management for GNU |
| @@ -25,34 +26,34 @@ | |||
| 25 | ;; It's okay to import modules from core Guile though. | 26 | ;; It's okay to import modules from core Guile though. |
| 26 | (use-modules (srfi srfi-26)) | 27 | (use-modules (srfi srfi-26)) |
| 27 | 28 | ||
| 28 | (let () | 29 | (define-syntax-rule (push! elt v) (set! v (cons elt v))) |
| 29 | (define-syntax-rule (push! elt v) (set! v (cons elt v))) | ||
| 30 | 30 | ||
| 31 | (define (maybe-augment-load-paths!) | 31 | (define (augment-load-paths!) |
| 32 | (unless (getenv "GUIX_UNINSTALLED") | 32 | ;; Add installed modules to load-path. |
| 33 | (push! "@guilemoduledir@" %load-path) | 33 | (push! "@guilemoduledir@" %load-path) |
| 34 | (push! "@guileobjectdir@" %load-compiled-path) | 34 | (push! "@guileobjectdir@" %load-compiled-path) |
| 35 | (let ((updates-dir (and=> (or (getenv "XDG_CONFIG_HOME") | ||
| 36 | (and=> (getenv "HOME") | ||
| 37 | (cut string-append <> "/.config"))) | ||
| 38 | (cut string-append <> "/guix/latest")))) | ||
| 39 | (when (and updates-dir (file-exists? updates-dir)) | ||
| 40 | ;; XXX: Currently 'guix pull' puts both .scm and .go files in | ||
| 41 | ;; UPDATES-DIR. | ||
| 42 | (push! updates-dir %load-path) | ||
| 43 | (push! updates-dir %load-compiled-path))))) | ||
| 44 | 35 | ||
| 45 | (define (run-guix-main) | 36 | ;; Add modules fetched by 'guix pull' to load-path. |
| 46 | (let ((guix-main (module-ref (resolve-interface '(guix ui)) | 37 | (let ((updates-dir (and=> (or (getenv "XDG_CONFIG_HOME") |
| 47 | 'guix-main))) | 38 | (and=> (getenv "HOME") |
| 48 | (bindtextdomain "guix" "@localedir@") | 39 | (cut string-append <> "/.config"))) |
| 49 | (bindtextdomain "guix-packages" "@localedir@") | 40 | (cut string-append <> "/guix/latest")))) |
| 50 | (apply guix-main (command-line)))) | 41 | (when (and=> updates-dir file-exists?) |
| 42 | ;; XXX: Currently 'guix pull' puts both .scm and .go files in | ||
| 43 | ;; UPDATES-DIR. | ||
| 44 | (push! updates-dir %load-path) | ||
| 45 | (push! updates-dir %load-compiled-path)))) | ||
| 51 | 46 | ||
| 52 | (maybe-augment-load-paths!) | 47 | (define* (main #:optional (args (command-line))) |
| 48 | (unless (getenv "GUIX_UNINSTALLED") | ||
| 49 | (augment-load-paths!)) | ||
| 53 | 50 | ||
| 54 | ;; XXX: It would be more convenient to change it to: | 51 | (let ((guix-main (module-ref (resolve-interface '(guix ui)) |
| 55 | ;; (exit (run-guix-main)) | 52 | 'guix-main))) |
| 56 | ;; but since the 'guix' command is not updated by 'guix pull', we cannot | 53 | (bindtextdomain "guix" "@localedir@") |
| 57 | ;; really do it now. | 54 | (bindtextdomain "guix-packages" "@localedir@") |
| 58 | (run-guix-main)) | 55 | ;; XXX: It would be more convenient to change it to: |
| 56 | ;; (exit (apply guix-main (command-line))) | ||
| 57 | ;; but since the 'guix' command is not updated by 'guix pull', we cannot | ||
| 58 | ;; really do it now. | ||
| 59 | (apply guix-main args))) | ||
