[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 1e72a297d7 238/500: update
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 1e72a297d7 238/500: update |
Date: |
Sat, 29 Jan 2022 08:27:10 -0500 (EST) |
branch: elpa/nix-mode
commit 1e72a297d7b8bd734a38cf4a9e80c531335e8fef
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>
update
---
.dir-locals.el | 8 +++
nix-shell.el | 151 +++++++++++++++++++++++++++++++++++++++++----------------
nix.el | 30 ++----------
3 files changed, 122 insertions(+), 67 deletions(-)
diff --git a/.dir-locals.el b/.dir-locals.el
new file mode 100644
index 0000000000..6136e2ddbc
--- /dev/null
+++ b/.dir-locals.el
@@ -0,0 +1,8 @@
+;;; Directory Local Variables
+;;; For more information see (info "(emacs) Directory Variables")
+
+((nil
+ (eval nix-shell-with-string "let pkgs = import <nixpkgs> {};
+in pkgs.runCommand \"nix-mode-shell\" {
+ nativeBuildInputs = with pkgs; [ emacs git nix ];
+} \"\"")))
diff --git a/nix-shell.el b/nix-shell.el
index 8f7e44fd78..946bb073c9 100644
--- a/nix-shell.el
+++ b/nix-shell.el
@@ -24,16 +24,6 @@
"All nix-shell options."
:group 'nix)
-(defcustom nix-shell-file nil
- "Set to the file to run the nix-shell for."
- :type 'string
- :group 'nix-shell)
-
-(defcustom nix-shell-attribute nil
- "Set to the file to run the nix-shell for."
- :type 'string
- :group 'nix-shell)
-
(defcustom nix-shell-inputs '(depsBuildBuild
depsBuildBuildPropagated
nativeBuildInputs
@@ -55,6 +45,77 @@ Similar to ‘--pure’ argument in command line nix-shell."
:type 'boolean
:group 'nix-shell)
+(defcustom nix-file nil
+ "Nix file to build expressions from.
+Should only be set in dir-locals.el file."
+ :type 'stringp
+ :group 'nix-shell)
+
+(defcustom nix-attr nil
+ "Nix attribute path to use.
+Should only be set in dir-locals.el file."
+ :type 'stringp
+ :group 'nix-shell)
+
+;;;###autoload
+(defun nix-shell-unpack (file attr)
+ "Run Nix’s unpackPhase.
+FILE is the file to unpack from.
+ATTR is the attribute to unpack."
+ (interactive
+ (list
+ (if nix-file (expand-file-name nix-file (locate-dominating-file
+ (if (buffer-file-name)
+ (buffer-file-name)
+ default-directory)
+ dir-locals-file))
+ "<nixpkgs>")
+ (if nix-attr nix-attr (nix-search-read-attr "<nixpkgs>"))))
+ (nix-shell--run-phase "unpack" file attr))
+
+;;;###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 (expand-file-name nix-file (locate-dominating-file
+ (if (buffer-file-name)
+ (buffer-file-name)
+ default-directory)
+ dir-locals-file))
+ "<nixpkgs>")
+ (if nix-attr nix-attr (nix-search-read-attr "<nixpkgs>"))))
+ (nix-shell--run-phase "configure" file attr))
+
+;;;###autoload
+(defun nix-shell-build (file attr)
+ "Run Nix’s buildPhase.
+FILE is the file to build from.
+ATTR is the attribute to build."
+ (interactive
+ (list
+ (if nix-file (expand-file-name nix-file (locate-dominating-file
+ (if (buffer-file-name)
+ (buffer-file-name)
+ default-directory)
+ dir-locals-file))
+ "<nixpkgs>")
+ (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)
+ "Get source from a Nix derivation.
+PHASE phase to run.
+FILE used for base of Nix expresions.
+ATTR from NIX-FILE to get Nix expressions from."
+ (shell-command
+ (format "%s '%s' -A '%s' --run '
+if [ -z \"%sPhase\" ]; then eval %sPhase; else eval \"$%sPhase\"; fi' &"
+ nix-shell-executable
+ file attr phase phase phase)))
+
(defun nix-shell--callback (buffer drv)
"Run the nix-shell callback to setup the buffer.
The BUFFER to run in.
@@ -108,7 +169,6 @@ The DRV file to use."
(flycheck-buffer))
)))
-;;;###autoload
(defun nix-shell-with-packages (packages &optional pkgs-file)
"Create a nix shell environment from the listed package.
PACKAGES a list of packages to use.
@@ -150,16 +210,20 @@ PKGS-FILE a file to use to get the packages."
(eshell-mode)
buffer))
-(defun nix-eshell (&optional nix-file attribute)
+(defun nix-eshell (file &optional attr)
"Create an Eshell buffer that has the shell environment in it.
-NIX-FILE the .nix expression to create a shell for.
-ATTRIBUTE attribute to instantiate in NIX-FILE."
- (interactive)
-
- (unless nix-file
- (when nix-shell-file (setq nix-file nix-shell-file)))
-
- (unless nix-file (error "Cannot find .nix file"))
+FILE the .nix expression to create a shell for.
+ATTR attribute to instantiate in NIX-FILE."
+ (interactive
+ (list
+ (if nix-file (expand-file-name nix-file (locate-dominating-file
+ (if (buffer-file-name)
+ (buffer-file-name)
+ default-directory)
+ dir-locals-file))
+ "<nixpkgs>")
+ (when (not nix-file)
+ (if nix-attr nix-attr (nix-search-read-attr "<nixpkgs>")))))
(let ((buffer (generate-new-buffer "*nix-eshell*")))
(pop-to-buffer-same-window buffer)
@@ -168,34 +232,39 @@ ATTRIBUTE attribute to instantiate in NIX-FILE."
(nix-shell--callback
(current-buffer)
- (nix-instantiate nix-file attribute))
+ (nix-instantiate file attribute))
(eshell-mode)
buffer))
;;;###autoload
-(defun nix-shell (&optional nix-file attribute)
- "A nix-shell emulator in Emacs.
-NIX-FILE the file to instantiate.
-ATTRIBUTE an attribute of the Nix file to use."
- (interactive)
-
- (unless nix-file
- (when nix-shell-file (setq nix-file nix-shell-file)))
-
- (unless attribute
- (when nix-shell-attribute (setq attribute nix-shell-attribute)))
-
- (when nix-file
- (setq nix-file
- (expand-file-name nix-file (locate-dominating-file
- (if (buffer-file-name)
- (buffer-file-name)
- default-directory)
- dir-locals-file)))
+(defun nix-shell-with-string (string)
+ "A nix-shell emulator in Emacs from a string.
+STRING the nix expression to use."
+ (let ((file (make-temp-file "nix-shell" nil ".nix")))
+ (with-temp-file file (insert string))
(nix-instantiate-async (apply-partially 'nix-shell--callback
(current-buffer))
- nix-file attribute)))
+ file)))
+
+;;;###autoload
+(defun nix-shell (file &optional attr)
+ "A nix-shell emulator in Emacs.
+FILE the file to instantiate.
+ATTRIBUTE an attribute of the Nix file to use."
+ (interactive
+ (list
+ (if nix-file (expand-file-name nix-file (locate-dominating-file
+ (if (buffer-file-name)
+ (buffer-file-name)
+ default-directory)
+ dir-locals-file))
+ "<nixpkgs>")
+ (when (not nix-file)
+ (if nix-attr nix-attr (nix-search-read-attr "<nixpkgs>")))))
+ (nix-instantiate-async (apply-partially 'nix-shell--callback
+ (current-buffer))
+ file attr))
(provide 'nix-shell)
;;; nix-shell.el ends here
diff --git a/nix.el b/nix.el
index 02c92a1c16..721f3b5c72 100644
--- a/nix.el
+++ b/nix.el
@@ -153,30 +153,6 @@
(pcomplete-here)))
(pcomplete-here nix-commands))
-;;;###autoload
-(defun nix-build (&optional attr dir)
- "Run nix-build.
-ATTR is the attribute to build.
-DIR is the directory containing the Nix default.nix expression."
- (interactive)
- (unless dir (setq dir default-directory))
- (if attr
- (async-shell-command (format "%s %s -A %s" nix-build-executable dir
attr))
- (async-shell-command (format "%s %s" nix-build-executable dir))))
-
-;;;###autoload
-(defun nix-unpack (path attribute)
- "Get source from a Nix derivation.
-
-PATH used for base of Nix expresions.
-
-ATTRIBUTE from PATH to get Nix expressions from."
- (interactive (list (read-string "Nix path: " "<nixpkgs>")
- (read-string "Nix attribute name: ")))
- (async-shell-command (format "%s '%s' -A '%s' --run unpackPhase"
- nix-shell-executable
- path attribute)))
-
;;;###autoload
(define-minor-mode global-nix-mode
"Minor mode to enable Nix enhancements."
@@ -187,14 +163,16 @@ ATTRIBUTE from PATH to get Nix expressions from."
(add-to-list 'interpreter-mode-alist '("nix-shell" . nix-shebang-mode))
(add-to-list 'auto-mode-alist '("\\.nix\\'" . nix-mode))
;; (add-to-list 'auto-mode-alist '("\\.drv\\'" . nix-drv-mode))
- (add-hook 'after-change-major-mode-hook 'nix-shell))
+ ;; (add-hook 'after-change-major-mode-hook 'nix-shell)
+ )
(progn
(setq interpreter-mode-alist (remove '("nix-shell" . nix-shebang-mode)
interpreter-mode-alist))
(setq auto-mode-alist
(remove '("\\.drv\\'" . nix-drv-mode)
(remove '("\\.nix\\'" . nix-mode) auto-mode-alist)))
- (remove-hook 'after-change-major-mode-hook 'nix-shell))))
+ ;; (remove-hook 'after-change-major-mode-hook 'nix-shell)
+ )))
(provide 'nix)
;;; nix.el ends here
- [nongnu] elpa/nix-mode 1268096ba7 136/500: Merge pull request #27 from ljli/close-open-fix, (continued)
- [nongnu] elpa/nix-mode 1268096ba7 136/500: Merge pull request #27 from ljli/close-open-fix, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 676cc65daf 153/500: Add some README doc., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 732ce2f174 169/500: Remove case-fold-search setting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 3a6634378a 149/500: Allow nix-repl be in custom location, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ea649349b5 156/500: Fix syntax issue, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 9d0668f1d8 181/500: Ignore ''' in mmm-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 3294f8a2f8 180/500: Merge pull request #37 from dieggsy/cl-lib, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode b580c8045b 192/500: Prefer derived-mode-p when checking for specific major modes, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode d14dd9ce95 196/500: Don't assign to unbound variable: let-bind it locally instead, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 664fa51cfa 199/500: Remove mmm-mode/company feature detection, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1e72a297d7 238/500: update,
ELPA Syncer <=
- [nongnu] elpa/nix-mode 9242165717 359/500: Don’t skip over > in angle-path, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1ebfda9810 368/500: Inline use of `signum`., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 3022b9ef74 409/500: Skip descriptions in nix completions, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode aaf2b741fb 410/500: nix-shell: skip non-default packages integration, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 458c83f8bd 396/500: Correct pacakge lint for dep., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 59f3ea4da9 401/500: make run: use -Q, ELPA Syncer, 2022/01/29