branch: elpa/nix-mode
commit 93bfb4428de869f8dc3d1339fbaa5971ed83c5ef
Author: Matthew Bauer <[email protected]>
Commit: Matthew Bauer <[email protected]>
Add nix-build function.
I use this in nixpkgs a lot. Instead of a terminal just open a dired window
and
type:
M-x nix-build
followed by what attribute you want to build.
---
nix-mode.el | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/nix-mode.el b/nix-mode.el
index 6f32252b93..27308320b3 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -464,6 +464,17 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
(when (require 'mmm-mode nil 'noerror) (require 'nix-mode-mmm nil 'noerror))
+;;;###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 "sNix attribute: ")
+ (unless dir (setq dir default-directory))
+ (if attr
+ (shell-command (format "nix-build %s -A %s" dir attr))
+ (shell-command (format "nix-build %s" dir))))
+
;;;###autoload
(define-derived-mode nix-mode prog-mode "Nix"
"Major mode for editing Nix expressions.