From 0cb2057a76d74bc7ac342202d80f1be63474d86f Mon Sep 17 00:00:00 2001 From: sterni Date: Mon, 3 Apr 2023 17:44:22 +0200 Subject: 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 Tested-by: BuildkiteCI Reviewed-by: tazjin --- tools/emacs-pkgs/tvl/tvl.el | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/emacs-pkgs/tvl/tvl.el b/tools/emacs-pkgs/tvl/tvl.el index 46dbe0ca68..8db718a835 100644 --- a/tools/emacs-pkgs/tvl/tvl.el +++ b/tools/emacs-pkgs/tvl/tvl.el @@ -199,7 +199,7 @@ passes. This is potentially dangerous, use with care." (magit-status-setup-buffer tvl-depot-path)) (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 from the depot. @@ -207,12 +207,21 @@ passes. This is potentially dangerous, use with care." asynchronously. The build output is included in the error 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))) (errbuf (get-buffer-create (format "*depot-errors/%s*" attribute))) - (expression (format "(import {}).%s.repl" attribute)) + (attr-display (if only-deps attribute (format "dependencies of %s" attribute))) + (expression (if only-deps + (format "let d = import {}; in d.nix.buildLisp.sbcl.lispWith d.%s.lispDeps" + attribute) + (format "(import {}).%s.repl" attribute))) (command (list "nix-build" "--no-out-link" "-I" (format "depot=%s" tvl-depot-path) "-E" expression))) - (message "Acquiring Lisp for .%s" attribute) + (message "Acquiring Lisp for .%s" attr-display) (make-process :name (format "depot-nix-build/%s" attribute) :buffer outbuf :stderr errbuf @@ -224,10 +233,10 @@ passes. This is potentially dangerous, use with care." ("finished\n" (let* ((outpath (s-trim (with-current-buffer outbuf (buffer-string)))) (lisp-path (s-concat outpath "/bin/sbcl"))) - (message "Acquired Lisp for .%s at %s" attribute lisp-path) + (message "Acquired Lisp for .%s at %s" attr-display lisp-path) (sly lisp-path))) (_ (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 errbuf))))))) -- cgit 1.4.1