SLY: Regen Nyxt profile when guix.scm is newer.

master
Pierre Neidhardt 2020-12-18 19:12:38 +01:00
parent b4248b4226
commit f9248616f0
1 changed files with 22 additions and 19 deletions

View File

@ -18,42 +18,45 @@
(setq sly-lisp-implementations (setq sly-lisp-implementations
`((sbcl-ambrevar ("lisp-repl-core-dumper" "sbcl" "ambrevar")) `((sbcl-ambrevar ("lisp-repl-core-dumper" "sbcl" "ambrevar"))
(sbcl ("lisp-repl-core-dumper" "sbcl")) (sbcl ("lisp-repl-core-dumper" "sbcl"))
;; Simple REPL environment (no container): (sbcl-nyxt ;; Faster, but not pure. TODO: Can we purify it? Run it in a container? Try `env -i bash --noprofile --norc...`.
(sbcl-nyxt ("guix" "environment" "--pure"
"--preserve=^PERSONAL$" ; To find personal config, like engines and bookmarks.
"-l" ,(expand-file-name "~/common-lisp/nyxt/build-scripts/guix.scm")
;; glib is needed to export GIO_EXTRA_MODULES.
"--ad-hoc" "glib" "glib-networking" "gsettings-desktop-schemas"
"gnupg" "--" "sbcl"))
(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: Add easy way to reload: must delete profile. No need to delete dump if we use -f.
;; TODO: Extract to a separate function. ;; TODO: Extract to separate functions.
(lambda () (lambda ()
;; TODO: Replace root when guix.scm is newer. (let* ((guix-def (expand-file-name "~/common-lisp/nyxt/build-scripts/guix.scm"))
(let ((root (expand-file-name "~/.guix-temp-profiles/nyxt")) (guix-def-mtime (file-attribute-modification-time (file-attributes guix-def)))
(cache (expand-file-name "~/.cache/lisp-repl-core-nyxt")) (root (expand-file-name "~/.guix-temp-profiles/nyxt"))
(setup-file (ambrevar/prepare-sbcl-for-nyxt))) (root-mtime (file-attribute-modification-time (file-attributes root)))
(unless (file-exists-p 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) (make-directory (file-name-directory root) :parents)
(call-process "guix" nil nil nil (call-process "guix" nil nil nil
"environment" "--pure" "environment" "--pure"
"--preserve=^PERSONAL$" ; To find personal config, like engines and bookmarks. "--preserve=^PERSONAL$" ; To find personal config, like engines and bookmarks.
"-r" root "-r" root
"-l" (expand-file-name "~/common-lisp/nyxt/build-scripts/guix.scm") "-l" guix-def
"--ad-hoc" "glib" "glib-networking" "gsettings-desktop-schemas" "--ad-hoc" "glib" "glib-networking" "gsettings-desktop-schemas"
;; "nss-certs" ; Only needed in containers. ;; "nss-certs" ; Only needed in containers.
;; "libfixposix" ; TODO: We should not need this. ;; "libfixposix" ; TODO: We should not need this. Delete if there is no issue after a while (Jan 2021?).
"gnupg" "gnupg" ; For user .gpg decryption.
"coreutils" "coreutils" ; For "env".
"lisp-repl-core-dumper" "lisp-repl-core-dumper"
"--" "env" (concat "LISP_REPL_CORE_PATH=" cache) "--" "env" (concat "LISP_REPL_CORE_PATH=" cache)
"lisp-repl-core-dumper" "-f" "-g" (format "--load %s" setup-file) "sbcl") "lisp-repl-core-dumper" "-f" "-g" (format "--load %s" setup-file) "sbcl")
(let ((delete-by-moving-to-trash nil)) (let ((delete-by-moving-to-trash nil))
(delete-file setup-file))) (delete-file setup-file)))
`(("bash" "-c" ,(concat `(("bash" "-c" ,(concat
(format "source '%s/etc/profile'" root) (format "source '%s/etc/profile'" root)
" && LISP_REPL_CORE_PATH=" cache " && LISP_REPL_CORE_PATH=" cache
" lisp-repl-core-dumper sbcl")))))) " lisp-repl-core-dumper sbcl"))))))
;; Simple REPL environment (no container):
(sbcl-nyxt-failsafe ("guix" "environment" "--pure"
"--preserve=^PERSONAL$" ; To find personal config, like engines and bookmarks.
"-l" ,(expand-file-name "~/common-lisp/nyxt/build-scripts/guix.scm")
;; glib is needed to export GIO_EXTRA_MODULES.
"--ad-hoc" "glib" "glib-networking" "gsettings-desktop-schemas"
"gnupg" "--" "sbcl"))
(sbcl-nyxt-site ("guix" "environment" "--pure" (sbcl-nyxt-site ("guix" "environment" "--pure"
"-m" ,(expand-file-name "~/common-lisp/nyxt-site/guix-manifest.scm") "-m" ,(expand-file-name "~/common-lisp/nyxt-site/guix-manifest.scm")
"--" "sbcl")) "--" "sbcl"))