SLY: Extract sbcl-nyxt implementation to separate functions.
parent
f9248616f0
commit
5ec387b667
|
@ -13,6 +13,62 @@
|
|||
(asdf:system-depends-on (asdf:find-system :nyxt/gtk))))))))
|
||||
file))
|
||||
|
||||
(cl-defun ambrevar/guix-environment (&key root
|
||||
(pure? t)
|
||||
(preserve-args '())
|
||||
load
|
||||
(packages '())
|
||||
(ad-hoc-args '())
|
||||
(command-args '()))
|
||||
(apply #'call-process "guix" nil nil nil
|
||||
`("environment"
|
||||
,(when pure?
|
||||
"--pure")
|
||||
,@(when preserve-args
|
||||
(mapcar (lambda (s) (format "--preserve=^%s$" s))
|
||||
preserve-args))
|
||||
,(when root
|
||||
(concat "--root=" root))
|
||||
,(when load
|
||||
(concat "--load=" load))
|
||||
,@packages
|
||||
,@(when ad-hoc-args
|
||||
(cons "--ad-hoc" ad-hoc-args))
|
||||
,@(when command-args
|
||||
(cons "--" command-args)))))
|
||||
|
||||
(cl-defun ambrevar/lisp-implementation-from-guix-environment (&rest args
|
||||
&key (load (error "Must provide file to load."))
|
||||
ad-hoc-args
|
||||
command-args
|
||||
&allow-other-keys)
|
||||
"Wrapper over `ambrevar/guix-environment'."
|
||||
(let* ((load-mtime (when load
|
||||
(file-attribute-modification-time (file-attributes load))))
|
||||
(root (or (cl-getf args :root)
|
||||
(concat (expand-file-name "~/.guix-temp-profiles/")
|
||||
(file-name-sans-extension load))))
|
||||
(root-mtime (file-attribute-modification-time (file-attributes root)))
|
||||
(cache (concat (expand-file-name "~/.cache/lisp-repl-core-")
|
||||
(file-name-base root))))
|
||||
(unless (and (file-exists-p root)
|
||||
(or (not load-mtime)
|
||||
(time-less-p load-mtime root-mtime)))
|
||||
(cl-remf args :ad-hoc-args)
|
||||
(cl-pushnew "lisp-repl-core-dumper" ad-hoc-args)
|
||||
(cl-pushnew "coreutils" ad-hoc-args)
|
||||
(setf command-args (append (list "env" (concat "LISP_REPL_CORE_PATH=" cache))
|
||||
command-args))
|
||||
(make-directory (file-name-directory root) :parents)
|
||||
(apply #'ambrevar/guix-environment (append (list :root root)
|
||||
(list :ad-hoc-args ad-hoc-args)
|
||||
(list :command-args command-args)
|
||||
args)))
|
||||
`(("bash" "-c" ,(concat
|
||||
(format "source '%s/etc/profile'" root)
|
||||
" && LISP_REPL_CORE_PATH=" cache
|
||||
" lisp-repl-core-dumper sbcl")))))
|
||||
|
||||
(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
|
||||
|
@ -20,36 +76,22 @@
|
|||
(sbcl ("lisp-repl-core-dumper" "sbcl"))
|
||||
(sbcl-nyxt ;; 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 separate functions.
|
||||
(lambda ()
|
||||
(let* ((guix-def (expand-file-name "~/common-lisp/nyxt/build-scripts/guix.scm"))
|
||||
(guix-def-mtime (file-attribute-modification-time (file-attributes guix-def)))
|
||||
(root (expand-file-name "~/.guix-temp-profiles/nyxt"))
|
||||
(root-mtime (file-attribute-modification-time (file-attributes root)))
|
||||
(cache (expand-file-name "~/.cache/lisp-repl-core-nyxt"))
|
||||
(setup-file (ambrevar/prepare-sbcl-for-nyxt)))
|
||||
(unless (and (file-exists-p root)
|
||||
(time-less-p guix-def-mtime root-mtime))
|
||||
(make-directory (file-name-directory root) :parents)
|
||||
(call-process "guix" nil nil nil
|
||||
"environment" "--pure"
|
||||
"--preserve=^PERSONAL$" ; To find personal config, like engines and bookmarks.
|
||||
"-r" root
|
||||
"-l" guix-def
|
||||
"--ad-hoc" "glib" "glib-networking" "gsettings-desktop-schemas"
|
||||
;; "nss-certs" ; Only needed in containers.
|
||||
;; "libfixposix" ; TODO: We should not need this. Delete if there is no issue after a while (Jan 2021?).
|
||||
"gnupg" ; For user .gpg decryption.
|
||||
"coreutils" ; For "env".
|
||||
"lisp-repl-core-dumper"
|
||||
"--" "env" (concat "LISP_REPL_CORE_PATH=" cache)
|
||||
"lisp-repl-core-dumper" "-f" "-g" (format "--load %s" setup-file) "sbcl")
|
||||
(let ((root (expand-file-name "~/.guix-temp-profiles/nyxt"))
|
||||
(setup-file (ambrevar/prepare-sbcl-for-nyxt)))
|
||||
(prog1
|
||||
(ambrevar/lisp-implementation-from-guix-environment
|
||||
:root root
|
||||
:load "~/common-lisp/nyxt/build-scripts/guix.scm"
|
||||
:preserve-args '("PERSONAL")
|
||||
:ad-hoc-args '("glib" "glib-networking" "gsettings-desktop-schemas"
|
||||
;; "nss-certs" ; Only needed in containers.
|
||||
;; "libfixposix" ; TODO: We should not need this. Delete if there is no issue after a while (Jan 2021?).
|
||||
;; For user .gpg decryption:
|
||||
"gnupg")
|
||||
:command-args `("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
|
||||
" lisp-repl-core-dumper sbcl"))))))
|
||||
(delete-file setup-file))))))
|
||||
;; Simple REPL environment (no container):
|
||||
(sbcl-nyxt-failsafe ("guix" "environment" "--pure"
|
||||
"--preserve=^PERSONAL$" ; To find personal config, like engines and bookmarks.
|
||||
|
|
Loading…
Reference in New Issue