SLY: Leverage Nyxt's nyxt-guix.el instead of half-baked code.
parent
5ea702d757
commit
bb8c1a987a
|
@ -3,18 +3,6 @@
|
|||
(require 'patch-sly-prompt)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defun pure-env (&rest preserve-vars)
|
||||
"Return a pure `env' command as a list of string."
|
||||
(append '("env" "-i")
|
||||
(mapcar (lambda (var) (concat var "=" (getenv var)))
|
||||
(append
|
||||
'("DISPLAY"
|
||||
"HOME"
|
||||
"LOGNAME"
|
||||
"TERM"
|
||||
"USER")
|
||||
preserve-vars))))
|
||||
|
||||
(defun ambrevar/delete-lisp-image-dump ()
|
||||
"Delete SLY current connection image dump.
|
||||
This dump is expected to be generated by `lisp-repl-core-dumper'."
|
||||
|
@ -32,52 +20,7 @@ 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))))
|
||||
|
||||
(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.
|
||||
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 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))))
|
||||
(when (or refresh
|
||||
(not (file-exists-p root))
|
||||
(time-less-p (mtime root) (mtime guix-def))
|
||||
(time-less-p (mtime root) (mtime guix-sbcl-def))
|
||||
(time-less-p (mtime root) (mtime guix-checkout)))
|
||||
(make-directory (file-name-directory root) :parents)
|
||||
(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.
|
||||
(concat "--profile=" root)
|
||||
(concat "--install-from-file=" guix-sbcl-def))
|
||||
(when no-grafts?
|
||||
(list "--no-grafts")))))
|
||||
(message "Running %S" (mapconcat #'identity (cons command args) " "))
|
||||
(let* ((output (get-buffer-create " *Guix SBCL for Nyxt*"))
|
||||
(status (apply #'call-process command nil `(,output t) nil args)))
|
||||
(if (= status 0)
|
||||
(kill-buffer output)
|
||||
(switch-to-buffer-other-window output)
|
||||
(error "Guix command failed, see %s" output))))
|
||||
;; 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))
|
||||
`((,@(pure-env "PERSONAL")
|
||||
,(executable-find "bash") "--norc" "--noprofile" "-c"
|
||||
,(concat (format "source '%s/etc/profile'" root)
|
||||
" && sbcl"))))))
|
||||
(load "~/projects/nyxt/build-scripts/nyxt-guix.el" :noerror)
|
||||
|
||||
;; 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?
|
||||
|
@ -92,8 +35,7 @@ GUIX-COMMAND is the command to the guix executable, e.g. '(\"~/projects/guix/pre
|
|||
"--eval" "(named-readtables:in-readtable ambrevar/syntax:syntax)"))
|
||||
(sbcl (,@maybe-core-dumper "sbcl"))
|
||||
(sbcl-failsafe ("sbcl"))
|
||||
(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 (lambda () (nyxt-make-guix-sbcl-for-nyxt "~/projects/nyxt" :preserve '("PERSONAL"))))
|
||||
(sbcl-nyxt-pre-inst-env
|
||||
(,(expand-file-name "~/projects/guix/pre-inst-env")
|
||||
"guix" "environment" "-l"
|
||||
|
|
Loading…
Reference in New Issue