[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 420cbbf94c 215/500: Reorganization
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 420cbbf94c 215/500: Reorganization |
Date: |
Sat, 29 Jan 2022 08:27:08 -0500 (EST) |
branch: elpa/nix-mode
commit 420cbbf94c9abac9f8277e4cb3c04cb7f171d101
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>
Reorganization
Move around some files. Add ‘nix.el’ that is now the main entry point
to configurations. If you want the full experience of Nix integration
into Emacs, try running this (if you are already using use-package):
(use-package 'nix
:ensure 'nix-mode
:demand
:config (global-nix-mode))
Otherwise you can still do something like this:
(use-package 'nix-mode
:mode "\\.nix\\'"))
---
nix-company.el | 4 ---
nix-drv-mode.el | 45 ++++++++++++++++++++++++
nix-mode.el | 34 ++++--------------
nix-repl.el | 7 ++--
nix-shebang.el | 4 ---
nix-shell.el | 59 -------------------------------
nix.el | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 161 insertions(+), 99 deletions(-)
diff --git a/nix-company.el b/nix-company.el
index 9cc0648cf1..3c6abf0ab6 100644
--- a/nix-company.el
+++ b/nix-company.el
@@ -69,9 +69,5 @@ BUFFER check for Nix-REPL in current buffer"
(setq nix--company-last-buffer (buffer-name))))
backend-buf)))
-;; install nix-company
-(add-hook 'nix-mode-hook (lambda ()
- (setq-local company-backends '(company-nix))))
-
(provide 'nix-company)
;;; nix-company.el ends here
diff --git a/nix-drv-mode.el b/nix-drv-mode.el
new file mode 100644
index 0000000000..a0eb60c0f4
--- /dev/null
+++ b/nix-drv-mode.el
@@ -0,0 +1,45 @@
+;;; nix-drv-mode.el --- Major mode for viewing .drv files
+
+;; Maintainer: Matthew Bauer <mjbauer95@gmail.com>
+;; Homepage: https://github.com/NixOS/nix-mode
+;; Version: 1.2.1
+;; Keywords: nix, languages, tools, unix
+;; Package-Requires: ((emacs "24.3"))
+
+;; This file is NOT part of GNU Emacs.
+
+;;; Commentary:
+
+;; A major mode for viewing Nix derivations (.drv files). See the Nix
+;; manual for more information available at
+;; https://nixos.org/nix/manual/.
+
+;;; Code:
+
+(require 'json-mode)
+(require 'nix)
+
+(defvar-local nix-drv-mode nil)
+
+;;;###autoload
+(defun nix-drv-mode ()
+ "Pretty print Nix’s .drv files."
+ (interactive)
+ (let ((inhibit-read-only t))
+ (if nix-drv-mode
+ (progn
+ (erase-buffer)
+ (insert-file-contents (buffer-file-name))
+ (setq nix-drv-mode nil))
+ (setq nix-drv-mode t)
+ (erase-buffer)
+ (insert (shell-command-to-string
+ (format "%s show-derivation \"%s\""
+ nix-executable
+ (buffer-file-name))))
+ (json-mode))
+ (set-buffer-modified-p nil)
+ (read-only-mode 1)))
+
+(provide 'nix-drv-mode)
+;;; nix-drv-mode.el ends here
diff --git a/nix-mode.el b/nix-mode.el
index 21429fa5a9..1b25d091ad 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -15,12 +15,12 @@
;;; Code:
+(require 'nix)
(require 'nix-format)
-(require 'nix-shebang)
-(defgroup nix nil
- "Nix-related customizations"
- :group 'languages)
+(defgroup nix-mode nil
+ "Nix mode customizations"
+ :group 'nix)
(defcustom nix-indent-function 'indent-relative
"The function to use to indent.
@@ -29,16 +29,12 @@ Valid functions for this are:
- indent-relative
- nix-indent-line (buggy)"
- :group 'nix
+ :group 'nix-mode
:type 'function)
-(defgroup nix-mode nil
- "Nix mode customizations"
- :group 'nix)
-
(defgroup nix-faces nil
"Nix faces."
- :group 'nix
+ :group 'nix-mode
:group 'faces)
(defface nix-keyword-face
@@ -438,7 +434,7 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
(defun nix-create-keymap ()
"Create the keymap associated with the Nix mode."
- (define-key nix-mode-map "\C-c\C-r" 'nix-format-buffer))
+ )
(defun nix-create-menu ()
"Create the Nix menu as shown in the menu bar."
@@ -450,17 +446,6 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
(nix-create-keymap)
(nix-create-menu)
-;;;###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 "nix-build %s -A %s" dir attr))
- (async-shell-command (format "nix-build %s" dir))))
-
;;;###autoload
(define-derived-mode nix-mode prog-mode "Nix"
"Major mode for editing Nix expressions.
@@ -518,10 +503,5 @@ The hook `nix-mode-hook' is run when Nix mode is started.
(easy-menu-add nix-mode-menu nix-mode-map))
-;;;###autoload
-(progn
- (add-to-list 'auto-mode-alist '("\\.nix\\'" . nix-mode))
- (add-to-list 'auto-mode-alist '("\\.nix.in\\'" . nix-mode)))
-
(provide 'nix-mode)
;;; nix-mode.el ends here
diff --git a/nix-repl.el b/nix-repl.el
index e8962806cd..036b697e9f 100644
--- a/nix-repl.el
+++ b/nix-repl.el
@@ -9,15 +9,12 @@
(defvar nix-prompt-regexp "nix-repl> ")
(require 'comint)
+(require 'nix)
(defgroup nix-repl nil
"nix-repl customizations"
:group 'nix)
-(defcustom nix-repl-executable "nix"
- "Location of nix-repl command."
- :type 'string)
-
(defcustom nix-repl-executable-args '("repl")
"Arguments to provide to nix-repl."
:type 'list)
@@ -53,7 +50,7 @@
"Make Nix Repl in BUFFER."
(apply
'make-comint-in-buffer
- (append `("Nix-REPL" ,buffer ,nix-repl-executable nil)
+ (append `("Nix-REPL" ,buffer ,nix-executable nil)
nix-repl-executable-args)))
(defun nix-get-completions (proc prefix)
diff --git a/nix-shebang.el b/nix-shebang.el
index 0edf939a5b..08cc1629dd 100644
--- a/nix-shebang.el
+++ b/nix-shebang.el
@@ -43,9 +43,5 @@
interpreter-mode-alist)
#'string-match-p)))))
-;; WARNING: this will automatically modify interpreter-mode-alist
-;; ideally we could make this opt-in
-(add-to-list 'interpreter-mode-alist '("nix-shell" . nix-shebang-mode))
-
(provide 'nix-shebang)
;;; nix-shebang.el ends here
diff --git a/nix-shell.el b/nix-shell.el
deleted file mode 100644
index ca3dec72d2..0000000000
--- a/nix-shell.el
+++ /dev/null
@@ -1,59 +0,0 @@
-;;; nix-shell.el -- run nix-shell in Emacs -*- lexical-binding: t -*-
-
-;; Author: Matthew Bauer <mjbauer95@gmail.com>
-;; Homepage: https://github.com/NixOS/nix-mode
-;; Keywords: nix
-
-;; This file is NOT part of GNU Emacs.
-
-;;; Commentary:
-
-;; To use this just run:
-
-;; M-x RET nix-shell RET
-
-;; This will give you some
-
-;;; Code:
-
-;; (require 'nix-mode)
-(require 'term)
-
-(defgroup nix-shell nil
- "Customizations for nix-shell"
- :group 'nix)
-
-(defcustom nix-shell-executable "nix-shell"
- "Location of ‘nix-shell’ executable."
- :group 'nix-shell
- :type 'string)
-
-;;;###autoload
-(defun nix-shell (path attribute)
- "Run ‘nix-shell’ in a terminal.
-
-PATH path containing Nix expressions.
-ATTRIBUTE attribute name in nixpkgs to use."
- (interactive
- (list (read-from-minibuffer "Nix path: " "<nixpkgs>")
- (read-from-minibuffer "Nix attribute name: ")))
- (set-buffer (make-term "nix-shell" nix-shell-executable nil
- path "-A" attribute))
- (term-mode)
- (term-char-mode)
- (switch-to-buffer "*nix-shell*"))
-
-;;;###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)))
-
-(provide 'nix-shell)
-;;; nix-shell.el ends here
diff --git a/nix.el b/nix.el
new file mode 100644
index 0000000000..f6215b5be2
--- /dev/null
+++ b/nix.el
@@ -0,0 +1,107 @@
+;;; nix.el -- run nix commands in Emacs -*- lexical-binding: t -*-
+
+;; Author: Matthew Bauer <mjbauer95@gmail.com>
+;; Homepage: https://github.com/NixOS/nix-mode
+;; Keywords: nix
+
+;; This file is NOT part of GNU Emacs.
+
+;;; Commentary:
+
+;; To use this just run:
+
+;; M-x RET nix-shell RET
+
+;; This will give you some
+
+;;; Code:
+
+(require 'term)
+
+(require 'nix-mode)
+(require 'nix-shebang)
+(require 'nix-company)
+
+(defgroup nix nil
+ "Nix-related customizations"
+ :group 'languages)
+
+(defcustom nix-executable "nix"
+ "Nix executable location."
+ :group 'nix)
+
+(defcustom nix-build-executable "nix-build"
+ "Nix-build executable location."
+ :group 'nix)
+
+(defcustom nix-instantiate-executable "nix-instantiate"
+ "Nix executable location."
+ :group 'nix)
+
+(defcustom nix-store-executable "nix-store"
+ "Nix executable location."
+ :group 'nix)
+
+(defcustom nix-shell-executable "nix-shell"
+ "Location of ‘nix-shell’ executable."
+ :group 'nix
+ :type 'string)
+
+;;;###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-shell (path attribute)
+ "Run ‘nix-shell’ in a terminal.
+
+PATH path containing Nix expressions.
+ATTRIBUTE attribute name in nixpkgs to use."
+ (interactive
+ (list (read-from-minibuffer "Nix path: " "<nixpkgs>")
+ (read-from-minibuffer "Nix attribute name: ")))
+ (set-buffer (make-term "nix-shell" nix-shell-executable nil
+ path "-A" attribute))
+ (term-mode)
+ (term-char-mode)
+ (switch-to-buffer "*nix-shell*"))
+
+;;;###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."
+ :require 'nix
+ :global t
+ (cond
+ (global-nix-mode
+ (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 'nix-mode-hook (lambda () (setq-local company-backends
'(company-nix))))
+ )
+ (t
+ ())))
+
+(provide 'nix)
+;;; nix.el ends here
- [nongnu] elpa/nix-mode 71fda1db41 373/500: add README section for nix-prettify-mode (#100), (continued)
- [nongnu] elpa/nix-mode 71fda1db41 373/500: add README section for nix-prettify-mode (#100), ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode fc68739bec 011/500: Fix syntax error, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode cb392d45b6 030/500: tweak indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ade1d49841 128/500: Fixup indentation logic., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 414a40fe54 131/500: Add hydra mode (#25), ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode f7fa332705 155/500: Add nix-shell custom group, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 6573b1d70e 145/500: Add nix-shell.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0af6073003 171/500: Add nix-mode to nix-mode group., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode af686b570c 159/500: Fix package-lint complaints., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 3fa526ee57 165/500: Add MELPA badges to READM.md, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 420cbbf94c 215/500: Reorganization,
ELPA Syncer <=
- [nongnu] elpa/nix-mode 1090226479 224/500: nix-repl-show -> nix-repl, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 588246b499 229/500: Fix escaping of characters, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode a5bf79a563 425/500: Merge pull request #120 from znewman01/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 7593b023a7 405/500: Merge pull request #110 from leungbk/repl-history, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1fdf8e654a 444/500: Merge pull request #132 from league/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 8e20de5ba7 462/500: Merge pull request #134 from nagy/store-path, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 01e37b6761 464/500: Merge pull request #139 from akirak/fix/nix-24-for-25, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 8a05b88eb3 448/500: Fix a typo, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 207e5c0a92 455/500: nix-format.el: Add nix-format-before-save, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 86b7195b3e 010/500: Use warning font lock for upper case vars, ELPA Syncer, 2022/01/29