emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/nix-mode 1be3ca4666 245/500: Clean up nix-shell.el


From: ELPA Syncer
Subject: [nongnu] elpa/nix-mode 1be3ca4666 245/500: Clean up nix-shell.el
Date: Sat, 29 Jan 2022 08:27:10 -0500 (EST)

branch: elpa/nix-mode
commit 1be3ca4666580f8bea459fa89658d20df2328e9e
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>

    Clean up nix-shell.el
---
 nix-shell.el | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/nix-shell.el b/nix-shell.el
index 227da5a9a5..61420a0bad 100644
--- a/nix-shell.el
+++ b/nix-shell.el
@@ -19,6 +19,7 @@
 (require 'nix)
 (require 'nix-instantiate)
 (require 'nix-store)
+(require 'nix-search)
 
 (defgroup nix-shell nil
   "All nix-shell options."
@@ -68,15 +69,21 @@ ATTR is the attribute to unpack."
     (if nix-attr nix-attr (nix-search-read-attr "<nixpkgs>"))))
   (nix-shell--run-phase "unpack" file attr))
 
+(defun nix-shell--find-file ()
+  (cond
+   (nix-file nix-file)
+   ((file-exists-p "shell.nix") "shell.nix")
+   ((file-exists-p "default.nix") "default.nix")
+   (t (read-file-name "Nix file: "))))
+
 ;;;###autoload
 (defun nix-shell-configure (file attr)
   "Run Nix’s configurePhase.
 FILE is the file to configure from.
 ATTR is the attribute to configure."
   (interactive
-   (list
-    (if nix-file nix-file "<nixpkgs>")
-    (if nix-attr nix-attr (nix-search-read-attr "<nixpkgs>"))))
+   (list (nix-shell--find-file)
+        (if nix-attr nix-attr (nix-search-read-attr "<nixpkgs>"))))
   (nix-shell--run-phase "configure" file attr))
 
 ;;;###autoload
@@ -85,9 +92,8 @@ ATTR is the attribute to configure."
 FILE is the file to build from.
 ATTR is the attribute to build."
   (interactive
-   (list
-    (if nix-file nix-file "<nixpkgs>")
-    (if nix-attr nix-attr (nix-search-read-attr "<nixpkgs>"))))
+   (list (nix-shell--find-file)
+        (if nix-attr nix-attr (nix-search-read-attr "<nixpkgs>"))))
   (nix-shell--run-phase "build" file attr))
 
 (defun nix-shell--run-phase (phase file attr)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]