feat(emacs-pkgs/tvl): allow starting sly only including dependencies

Usually the current behavior is best: You are dropped in a REPL with the
package(s) you are working on already available. As you are working on
them, you recompile individual files and your changes become available.

However, I've found that there are some occasions when this is not
desireable, e.g.: When you are working on something and have broken the
test suite intermittently, it becomes impossible to start a new REPL.

Not sure how the yes-or-no-p question should be phrased, its negation
may be better?

Change-Id: I6a37ebc02f3121f628fc9206e0de650851824cd6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8415
Autosubmit: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
sterni 2023-04-03 17:44:22 +02:00 committed by clbot
parent 8263c024c9
commit 0cb2057a76

View file

@ -199,7 +199,7 @@ passes. This is potentially dangerous, use with care."
(magit-status-setup-buffer tvl-depot-path)) (magit-status-setup-buffer tvl-depot-path))
(eval-after-load 'sly (eval-after-load 'sly
'(defun tvl-sly-from-depot (attribute) '(defun tvl-sly-from-depot (attribute only-deps)
"Start a Sly REPL configured with a Lisp matching a derivation "Start a Sly REPL configured with a Lisp matching a derivation
from the depot. from the depot.
@ -207,12 +207,21 @@ passes. This is potentially dangerous, use with care."
asynchronously. The build output is included in the error asynchronously. The build output is included in the error
thrown on build failures." thrown on build failures."
(interactive "sAttribute: ") ;; TODO(sterni): this function asumes that we are using SBCL
;; - for determining the resulting wrapper's location
;; - for creating the dep-only wrapper
(interactive (list (read-string "Attribute: ")
(yes-or-no-p "Only include dependencies? ")))
(lexical-let* ((outbuf (get-buffer-create (format "*depot-out/%s*" attribute))) (lexical-let* ((outbuf (get-buffer-create (format "*depot-out/%s*" attribute)))
(errbuf (get-buffer-create (format "*depot-errors/%s*" attribute))) (errbuf (get-buffer-create (format "*depot-errors/%s*" attribute)))
(expression (format "(import <depot> {}).%s.repl" attribute)) (attr-display (if only-deps attribute (format "dependencies of %s" attribute)))
(expression (if only-deps
(format "let d = import <depot> {}; in d.nix.buildLisp.sbcl.lispWith d.%s.lispDeps"
attribute)
(format "(import <depot> {}).%s.repl" attribute)))
(command (list "nix-build" "--no-out-link" "-I" (format "depot=%s" tvl-depot-path) "-E" expression))) (command (list "nix-build" "--no-out-link" "-I" (format "depot=%s" tvl-depot-path) "-E" expression)))
(message "Acquiring Lisp for <depot>.%s" attribute) (message "Acquiring Lisp for <depot>.%s" attr-display)
(make-process :name (format "depot-nix-build/%s" attribute) (make-process :name (format "depot-nix-build/%s" attribute)
:buffer outbuf :buffer outbuf
:stderr errbuf :stderr errbuf
@ -224,10 +233,10 @@ passes. This is potentially dangerous, use with care."
("finished\n" ("finished\n"
(let* ((outpath (s-trim (with-current-buffer outbuf (buffer-string)))) (let* ((outpath (s-trim (with-current-buffer outbuf (buffer-string))))
(lisp-path (s-concat outpath "/bin/sbcl"))) (lisp-path (s-concat outpath "/bin/sbcl")))
(message "Acquired Lisp for <depot>.%s at %s" attribute lisp-path) (message "Acquired Lisp for <depot>.%s at %s" attr-display lisp-path)
(sly lisp-path))) (sly lisp-path)))
(_ (with-current-buffer errbuf (_ (with-current-buffer errbuf
(error "Failed to build '%s':\n%s" attribute (buffer-string))))) (error "Failed to build %s:\nTried building '%s':\n%s" attr-display expression (buffer-string)))))
(kill-buffer outbuf) (kill-buffer outbuf)
(kill-buffer errbuf))))))) (kill-buffer errbuf)))))))