SLY: Make ambrevar/sbcl-for-nyxt more parameterized, add sbcl-nyxt-pre-inst-env.
parent
012b7b33c9
commit
344c1d78a6
|
@ -1,4 +1,5 @@
|
|||
(require 'patch-sly)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defun pure-env (&rest preserve-vars)
|
||||
"Return a pure `env' command as a list of string."
|
||||
|
@ -29,13 +30,18 @@ This dump is expected to be generated by `lisp-repl-core-dumper'."
|
|||
(message "%S deleted." command)))
|
||||
(message "%S is not a Lisp image dump." command))))
|
||||
|
||||
(defun ambrevar/sbcl-for-nyxt (&optional refresh) ;; TODO: Run it in a container?
|
||||
(cl-defun ambrevar/sbcl-for-nyxt (&key refresh ;; TODO: Run it in a container?
|
||||
(root "~/.guix-temp-profiles/nyxt/nyxt")
|
||||
(guix-command '("guix"))
|
||||
no-grafts?)
|
||||
"Fast, pure Guix environment for Nyxt development.
|
||||
If REFRESH is non-nil, rebuild the environment."
|
||||
If REFRESH is non-nil, rebuild the environment.
|
||||
ROOT is the path to the profile root.
|
||||
GUIX-COMMAND is the command to the guix executable, e.g. '(\"~/projects/guix/pre-inst-env\" \"guix\")"
|
||||
(cl-flet ((mtime (file)
|
||||
(when (file-exists-p file)
|
||||
(file-attribute-modification-time (file-attributes file)))))
|
||||
(let* ((root (expand-file-name "~/.guix-temp-profiles/nyxt/nyxt"))
|
||||
(let* ((root (expand-file-name root))
|
||||
(guix-def (expand-file-name "~/common-lisp/nyxt/build-scripts/guix.scm"))
|
||||
(guix-sbcl-def (expand-file-name "~/common-lisp/nyxt/build-scripts/guix-sbcl-for-nyxt.scm"))
|
||||
(guix-checkout (format "/var/guix/profiles/per-user/%s/current-guix" (user-login-name))))
|
||||
|
@ -45,12 +51,19 @@ If REFRESH is non-nil, rebuild the environment."
|
|||
(time-less-p (mtime root) (mtime guix-sbcl-def))
|
||||
(time-less-p (mtime root) (mtime guix-checkout)))
|
||||
(make-directory (file-name-directory root) :parents)
|
||||
(call-process "guix" nil nil nil "package"
|
||||
(let ((command (executable-find (car guix-command)))
|
||||
(args (append
|
||||
(cdr guix-command)
|
||||
(list
|
||||
"package"
|
||||
;; May be needed to avoid having to rebuild some packages
|
||||
;; after the REPL has started.
|
||||
"--no-grafts"
|
||||
(concat "--profile=" root)
|
||||
(concat "--install-from-file=" guix-sbcl-def))
|
||||
(when no-grafts?
|
||||
(list "--no-grafts")))))
|
||||
(message "Running %S" (mapconcat #'identity (cons command args) " "))
|
||||
(apply #'call-process command nil nil nil args))
|
||||
;; Update root mtime in case it's not changed.
|
||||
;; Can't use `set-file-times' on links.
|
||||
(call-process "touch" nil nil nil "-h" root))
|
||||
|
@ -60,6 +73,7 @@ If REFRESH is non-nil, rebuild the environment."
|
|||
" && sbcl"))))))
|
||||
|
||||
;; Warning: ,restart-lisp does not take changes into account, the buffer must be re-created.
|
||||
;; TODO: SLY: Add pre-inst-env SBCL, maybe ask for packages?
|
||||
(setq sly-lisp-implementations
|
||||
(let ((maybe-core-dumper (when-let ((exec (executable-find "lisp-repl-core-dumper")))
|
||||
(list exec))))
|
||||
|
@ -68,8 +82,15 @@ If REFRESH is non-nil, rebuild the environment."
|
|||
"--eval" "(named-readtables:in-readtable ambrevar/all:syntax)"))
|
||||
(sbcl (,@maybe-core-dumper "sbcl"))
|
||||
(sbcl-failsafe ("sbcl"))
|
||||
(sbcl-nyxt (lambda () (ambrevar/sbcl-for-nyxt)))
|
||||
(sbcl-nyxt-refresh (lambda () (ambrevar/sbcl-for-nyxt :refresh)))
|
||||
(sbcl-nyxt (lambda () (ambrevar/sbcl-for-nyxt :no-grafts? t)))
|
||||
(sbcl-nyxt-refresh (lambda () (ambrevar/sbcl-for-nyxt :refresh t :no-grafts? t)))
|
||||
(sbcl-nyxt-pre-inst-env
|
||||
(,(expand-file-name "~/projects/guix/pre-inst-env")
|
||||
"guix" "environment" "-l"
|
||||
,(expand-file-name "~/common-lisp/nyxt/build-scripts/guix.scm")
|
||||
;; ,(format "--root=%s" (expand-file-name "~/.guix-temp-profiles/nyxt-pre-inst-env/nyxt-pre-inst-env"))
|
||||
"--ad-hoc" "glib" "glib-networking" "gsettings-desktop-schemas"
|
||||
"--" "sbcl"))
|
||||
;; Simple REPL environment for Nyxt, in case sbcl-nyxt does not work.
|
||||
(sbcl-nyxt-failsafe ("guix" "environment" "--pure"
|
||||
"--preserve=^PERSONAL$" ; To find personal config, like engines and bookmarks.
|
||||
|
|
Loading…
Reference in New Issue