SLY: Preload all Nyxt dependencies for fastest startup.

master
Pierre Neidhardt 2020-12-18 18:55:20 +01:00
parent 4091831038
commit b4248b4226
1 changed files with 22 additions and 6 deletions

View File

@ -1,5 +1,18 @@
(require 'patch-sly)
(defun ambrevar/prepare-sbcl-for-nyxt () ; TODO: Move this to a cl-flet.
(let ((file (make-temp-file "sbcl")))
(with-temp-file file
(insert
(format "%S"
'(mapc #'asdf:load-system
(delete-if (lambda (s)
(string= "nyxt" (subseq s 0 (min (length s) 4))))
(append
(asdf:system-depends-on (asdf:find-system :nyxt))
(asdf:system-depends-on (asdf:find-system :nyxt/gtk))))))))
file))
(when (executable-find "lisp-repl-core-dumper")
;; Warning: ,restart-lisp does not take changes into account, the buffer must be re-created.
(setq sly-lisp-implementations
@ -12,12 +25,14 @@
;; glib is needed to export GIO_EXTRA_MODULES.
"--ad-hoc" "glib" "glib-networking" "gsettings-desktop-schemas"
"gnupg" "--" "sbcl"))
;; Faster, but not pure. TODO: Can we purify it? Run it in a container?
(sbcl-nyxt-fast
(sbcl-nyxt-fast ;; Faster, but not pure. TODO: Can we purify it? Run it in a container? Try `env -i bash --noprofile --norc...`.
;; TODO: Add easy way to reload: must delete profile. No need to delete dump if we use -f.
;; TODO: Extract to a separate function.
(lambda ()
;; TODO: Replace root when source has changed?
;; TODO: Replace root when guix.scm is newer.
(let ((root (expand-file-name "~/.guix-temp-profiles/nyxt"))
(cache (expand-file-name "~/.cache/lisp-repl-core-nyxt")))
(cache (expand-file-name "~/.cache/lisp-repl-core-nyxt"))
(setup-file (ambrevar/prepare-sbcl-for-nyxt)))
(unless (file-exists-p root)
(make-directory (file-name-directory root) :parents)
(call-process "guix" nil nil nil
@ -32,8 +47,9 @@
"coreutils"
"lisp-repl-core-dumper"
"--" "env" (concat "LISP_REPL_CORE_PATH=" cache)
"lisp-repl-core-dumper" "sbcl"))
;; TODO: Include Nyxt Lisp deps in core dump?
"lisp-repl-core-dumper" "-f" "-g" (format "--load %s" setup-file) "sbcl")
(let ((delete-by-moving-to-trash nil))
(delete-file setup-file)))
`(("bash" "-c" ,(concat
(format "source '%s/etc/profile'" root)
" && LISP_REPL_CORE_PATH=" cache