>From b6f8331455da1ffc4896b06cd2ee98e09b05be43 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Wed, 17 Jan 2018 19:55:49 +0100 Subject: [PATCH 2/2] guix: Refactor script. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * scripts/guix.in: Use ‘and-let*’ and remove empty surrounding ‘let’. (run-guix-main, maybe-augment-load-paths!): Inline them. --- scripts/guix.in | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/scripts/guix.in b/scripts/guix.in index af50a782b..f971398e8 100644 --- a/scripts/guix.in +++ b/scripts/guix.in @@ -23,36 +23,33 @@ ;; IMPORTANT: We must avoid loading any modules from Guix here, ;; because we need to adjust the guile load paths first. ;; It's okay to import modules from core Guile though. -(use-modules (srfi srfi-26)) -(let () - (define-syntax-rule (push! elt v) (set! v (cons elt v))) +(use-modules (srfi srfi-2) + (srfi srfi-26)) - (define (maybe-augment-load-paths!) - (unless (getenv "GUIX_UNINSTALLED") - (push! "@guilemoduledir@" %load-path) - (push! "@guileobjectdir@" %load-compiled-path) - (let ((updates-dir (and=> (or (getenv "XDG_CONFIG_HOME") - (and=> (getenv "HOME") - (cut string-append <> "/.config"))) - (cut string-append <> "/guix/latest")))) - (when (and updates-dir (file-exists? updates-dir)) - ;; XXX: Currently 'guix pull' puts both .scm and .go files in - ;; UPDATES-DIR. - (push! updates-dir %load-path) - (push! updates-dir %load-compiled-path))))) +(define-syntax-rule (push! elt v) (set! v (cons elt v))) - (define (run-guix-main) - (let ((guix-main (module-ref (resolve-interface '(guix ui)) - 'guix-main))) - (bindtextdomain "guix" "@localedir@") - (bindtextdomain "guix-packages" "@localedir@") - (apply guix-main (command-line)))) +(unless (getenv "GUIX_UNINSTALLED") + ;; Add installed modules to load-path. + (push! "@guilemoduledir@" %load-path) + (push! "@guileobjectdir@" %load-compiled-path) - (maybe-augment-load-paths!) + ;; Add modules fetched by 'guix pull' to load-path. + (and-let* ((conf-dir (or (getenv "XDG_CONFIG_HOME") + (and=> (getenv "HOME") + (cut string-append <> "/.config")))) + (updates-dir (string-append conf-dir "/guix/latest")) + ((file-exists? updates-dir))) + ;; XXX: Currently 'guix pull' puts both .scm and .go files in UPDATES-DIR. + (push! updates-dir %load-path) + (push! updates-dir %load-compiled-path))) +;; Run Guix. +(let ((guix-main (module-ref (resolve-interface '(guix ui)) 'guix-main))) + (bindtextdomain "guix" "@localedir@") + (bindtextdomain "guix-packages" "@localedir@") ;; XXX: It would be more convenient to change it to: ;; (exit (run-guix-main)) ;; but since the 'guix' command is not updated by 'guix pull', we cannot ;; really do it now. - (run-guix-main)) + (apply guix-main (command-line))) -- 2.15.1