[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 1b15a6e583 252/500: Merge pull request #46 from m
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 1b15a6e583 252/500: Merge pull request #46 from matthewbauer/develop |
Date: |
Sat, 29 Jan 2022 08:27:11 -0500 (EST) |
branch: elpa/nix-mode
commit 1b15a6e5830f91c1cde5a63029e10e4f290568eb
Merge: 57ac40d53b c462eb400b
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #46 from matthewbauer/develop
Develop branch
---
.gitignore | 8 ++
CHANGELOG.md | 9 ++
Cask | 7 ++
Makefile | 47 +++++++--
README.md | 58 +++++++++++
nix-company.el | 4 -
nix-drv-mode.el | 46 +++++++++
nix-instantiate.el | 100 ++++++++++++++++++
nix-mode.el | 39 ++------
nix-mode.nix | 3 +
nix-mode.org | 257 +++++++++++++++++++++++++++++++++++++++++++++++
nix-repl.el | 12 +--
nix-search.el | 60 +++++++++++
nix-shebang.el | 4 -
nix-shell-haskell.el | 107 ++++++++++++++++++++
nix-shell.el | 243 +++++++++++++++++++++++++++++++++++++++-----
nix-store.el | 25 +++++
nix.el | 278 +++++++++++++++++++++++++++++++++++++++++++++++++++
18 files changed, 1231 insertions(+), 76 deletions(-)
diff --git a/.gitignore b/.gitignore
index 9b4291b7fe..66a97ac24c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,11 @@
# Packaging
.cask
+
+# Nix
+result
+
+# Documentation
+*.html
+*.texi
+*.info
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 62c94e87ae..a9c0fab1fe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,15 @@
### Changes
+## 2.0
+
+* Added manual.
+
+### New files
+
+* nix.el: customization settings for nix installation
+*
+
## 1.2.1
### Changes
diff --git a/Cask b/Cask
index 51e6ddd692..0a1ae1d212 100644
--- a/Cask
+++ b/Cask
@@ -11,6 +11,13 @@
"nix-shell.el"
"nix-mode-mmm.el"
"nix-prettify-mode.el"
+ "nix-store.el"
+ "nix-instantiate.el"
+ "nix-drv-mode.el"
+ "nix-search.el"
+ "nix-shebang.el"
+ "nix.el"
+ "nix-shell-haskell.el"
)
(development
diff --git a/Makefile b/Makefile
index de4f6c31ef..52991ac33f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,47 @@
emacs ?= emacs
-LOAD = -l nix-mode.el
+.PHONY: test clean
-all: test
+ELS = nix.el nix-company.el nix-drv-mode.el nix-format.el \
+ nix-instantiate.el nix-mode.el nix-mode-mmm.el \
+ nix-prettify-mode.el nix-repl.el nix-search.el nix-shebang.el \
+ nix-shell.el nix-store.el
+ELCS = $(ELS:.el=.elc)
+
+DOCS = nix-mode.info nix-mode.html nix-mode.pdf
+
+all: $(ELCS) $(DOCS) test
test:
- $(emacs) -Q -batch $(LOAD) -l tests/nix-mode-tests.el -l
tests/nix-font-lock-tests.el -f ert-run-tests-batch-and-exit
+ emacs -Q -batch -l nix-mode.el \
+ -l tests/nix-mode-tests.el \
+ -l tests/nix-font-lock-tests.el \
+ -f ert-run-tests-batch-and-exit
-compile:
- $(emacs) -batch --eval "(progn (add-to-list 'load-path
default-directory) (mapc #'byte-compile-file '(\"nix-mode.el\")))"
+%.elc: %.el
+ emacs -Q -batch -L . --eval "(progn\
+ (when (file-exists-p \"$@\")\
+ (delete-file \"$@\"))\
+ (fset 'message* (symbol-function 'message))\
+ (fset 'message (lambda (f &rest a)\
+ (unless (equal f \"Wrote %s\")\
+ (apply 'message* f a)))))" \
+ -f batch-byte-compile $<
-clean:
- rm -f *.elc
+%.texi: %.org
+ emacs --batch -Q \
+ -l ox-extra -l org-man -l ox-texinfo.el $< \
+ -f org-texinfo-export-to-texinfo
+ @echo >> $@
+
+%.info: %.texi
+ makeinfo --no-split $< -o $@
-.PHONY: all compile clean test
+%.html: %.texi
+ makeinfo --html --no-split $<
+
+%.pdf: %.texi
+ texi2pdf --clean $< > /dev/null
+
+clean:
+ rm *.elc
diff --git a/README.md b/README.md
index ff0b79b2c7..f6cb67d6be 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,64 @@
An emacs major mode for editing nix expressions.
+## Recommended config
+
+```
+(use-package nix
+ :ensure nix-mode
+ :commands global-nix-mode
+ :init (global-nix-mode))
+```
+
+## Submodes
+
+A quick list of what is provided.
+
+### nix.el
+
+nix.el contains some miscellaneous tools for Nix developers.
+Interactive functions include:
+
+- nix-unpack - unpack source of a Nix attribute.
+
+ To use this just type:
+
+ M-x nix-unpack<RET>
+
+ Followed by your Nix path & attribute path.
+
+- nix-build - build a Nix derviation.
+
+ This is meant to work similarly to M-x compile. It will use your
+ current directory & build it if there is a default.nix there.
+
+nix.el also provides some basic functions for interfacing with Nix.
+Some variables are provided to point to the Nix binaries that can be
+used in Lisp code:
+
+- nix-executable
+- nix-build-executable
+- nix-instantiate-executable
+- nix-store-executable
+- nix-shell-executable
+
+Other useful functions for Lisp scripts are provided:
+
+- nix-system - Get the current system, detected by Nix
+
+### nix-repl.el
+
+nix-repl.el has two purposes.
+
+First, it provides an interface for completion, used by nix-company.el.
+
+Second, it provides an interactive function to open an repl. You can
+open this with:
+
+M-x nix-repl<RET>
+
+## Origins
+
This repository is based off of the nix-mode.el file originally located in
the [Nix repository](https://github.com/NixOS/nix)
at
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..fdbc4f82f9
--- /dev/null
+++ b/nix-drv-mode.el
@@ -0,0 +1,46 @@
+;;; 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))
+ (set-buffer-modified-p nil)
+ (read-only-mode 1)))
+
+(provide 'nix-drv-mode)
+;;; nix-drv-mode.el ends here
diff --git a/nix-instantiate.el b/nix-instantiate.el
new file mode 100644
index 0000000000..05607b4629
--- /dev/null
+++ b/nix-instantiate.el
@@ -0,0 +1,100 @@
+;;; nix-instantiate.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:
+
+;;; Code:
+
+(require 'nix)
+(require 'json)
+
+(defun nix-instantiate--parsed (drv)
+ "Get the parsed version of the .drv file.
+DRV file to load from."
+ (let ((stdout (generate-new-buffer "nix show-derivation"))
+ result)
+ (call-process nix-executable nil (list stdout nil) nil
+ "show-derivation" drv)
+ (setq result
+ (cdar (with-current-buffer stdout
+ (when (eq (buffer-size) 0)
+ (error "nix show-derivation %s failed to produce any output"
+ drv))
+ (goto-char (point-min))
+ (json-read))))
+ (kill-buffer stdout)
+ result))
+
+(defun nix-instantiate (nix-file &optional attribute)
+ "Run nix-instantiate on a Nix expression.
+NIX-FILE the file to instantiate.
+ATTRIBUTE an attribute of the Nix file to use."
+ (let ((stdout (generate-new-buffer "nix-instantiate"))
+ result)
+ (if attribute
+ (call-process nix-instantiate-executable nil (list stdout nil) nil
+ nix-file "-A" attribute)
+ (call-process nix-instantiate-executable nil (list stdout nil) nil
+ nix-file))
+ (with-current-buffer stdout
+ (when (eq (buffer-size) 0)
+ (error
+ "Error: nix-instantiate %s failed to produce any output"
+ nix-file))
+ (setq result (nix-instantiate--parsed
+ (substring (buffer-string) 0 (- (buffer-size) 1)))))
+ (kill-buffer stdout)
+ result))
+
+(defvar nix-instantiate--running-processes nil)
+
+(defun nix-instantiate--sentinel (prop err proc event)
+ "Make a nix-instantiate process.
+PROP the prop name of nix-instantiate--running-processes.
+ERR the error buffer.
+PROC the process that has been run.
+EVENT the event that was fired."
+ (when (string= event "finished\n")
+ (with-current-buffer (process-buffer proc)
+ (unless (eq (buffer-size) 0)
+ (let ((drv (nix-instantiate--parsed
+ (substring (buffer-string) 0 (- (buffer-size) 1)))))
+ (dolist
+ (callback (lax-plist-get nix-instantiate--running-processes prop))
+ (funcall callback drv)))))
+ (setq nix-instantiate--running-processes
+ (lax-plist-put nix-instantiate--running-processes prop nil)))
+ (unless (process-live-p proc)
+ (kill-buffer (process-buffer proc))
+ (kill-buffer err)))
+
+(defun nix-instantiate-async (callback nix-file &optional attribute)
+ "Run nix-instantiate on a Nix expression, asynchronously.
+CALLBACK the function to call when instantiate completes.
+NIX-FILE the file to instantiate
+ATTRIBUTE an attribute of the Nix file to use."
+ (setq nix-file (expand-file-name nix-file))
+ (let* ((prop (if attribute
+ (expand-file-name attribute nix-file) nix-file))
+ (data (lax-plist-get nix-instantiate--running-processes prop))
+ (stdout (generate-new-buffer "nix-instantiate"))
+ (stderr (generate-new-buffer "nix-instantiate error")))
+ (setq nix-instantiate--running-processes
+ (lax-plist-put nix-instantiate--running-processes
+ prop (cons callback data)))
+ (make-process
+ :name "nix-instantiate"
+ :buffer stdout
+ :command (append (list nix-instantiate-executable nix-file)
+ (when attribute (list "-A" attribute)))
+ :noquery t
+ :sentinel (apply-partially 'nix-instantiate--sentinel prop stderr)
+ :stderr stderr)))
+
+(provide 'nix-instantiate)
+;;; nix-instantiate.el ends here
diff --git a/nix-mode.el b/nix-mode.el
index 21429fa5a9..ea29241184 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -15,30 +15,29 @@
;;; Code:
+(require 'nix)
(require 'nix-format)
(require 'nix-shebang)
+(require 'nix-shell)
+(require 'nix-repl)
-(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.
Valid functions for this are:
-- indent-relative
+- ‘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 +437,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 +449,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.
@@ -491,7 +479,7 @@ The hook `nix-mode-hook' is run when Nix mode is started.
;; Recommended by nixpkgs manual:
https://nixos.org/nixpkgs/manual/#sec-syntax
(setq-local indent-tabs-mode nil)
(setq-local tab-width 2)
- (setq-local electric-indent-chars '(?\n ?{ ?} ?[ ?] ?( ?)))
+ (setq-local electric-indent-chars '(?\n ?{ ?} ?\[ ?\] ?\( ?\)))
;; Font lock support.
(setq-local font-lock-defaults '(nix-font-lock-keywords))
@@ -518,10 +506,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-mode.nix b/nix-mode.nix
new file mode 100644
index 0000000000..d0f56c6d0c
--- /dev/null
+++ b/nix-mode.nix
@@ -0,0 +1,3 @@
+with import <nixpkgs> {};
+
+emacsWithPackages (epkgs: [ epkgs.nix-mode ])
diff --git a/nix-mode.org b/nix-mode.org
new file mode 100644
index 0000000000..ab33d2d73d
--- /dev/null
+++ b/nix-mode.org
@@ -0,0 +1,257 @@
+* nix-mode User Manual
+
+** Introduction
+
+nix-mode started out as a simple major mode to edit Nix expressions.
+It still provides this, but, recently there has been an effort to
+provide more than just the .nix major mode. This documentation will
+provide some guidance in how to setup and use these new
+configurations.
+
+** Installation
+
+*** Installing from MELPA
+
+nix-mode is available from MELPA. You can set up MELPA by modifying
+package-archives in your ~/.emacs.d/init.el,
+
+#+BEGIN_SRC emacs-lisp
+(require 'package)
+(add-to-list 'package-archives
+ '("melpa" . "https://melpa.org/packages/") t)
+#+END_SRC
+
+Once the above has been executed, you can refresh your package cache
+with,
+
+#+BEGIN_SRC text
+M-x package-refresh-contents RET
+#+END_SRC
+
+Once this is done, you can install nix-mode with,
+
+#+BEGIN_SRC text
+M-x package-install RET nix-mode RET
+#+END_SRC
+
+*** Installing from Nix
+
+It is also possible to install nix-mode from Nix itself. This requires
+some knowledge of how to write a Nix expression. If you would like to
+see an example see nix-mode.nix in this Git repo. This file is an
+expression that contains a bundled Emacs with nix-mode preinstalled.
+
+*** Installing from Git
+
+You can also setup nix-mode through the Git repo directly. This is
+recommended if you are interested in contributing to nix-mode.
+
+#+BEGIN_SRC sh
+$ mkdir -p ~/.emacs.d/site-lisp
+$ git clone https://github.com/matthewbauer/nix-mode.git
~/.emacs.d/site-lisp/nix-mode
+$ cd ~/.emacs.d/site-lisp/nix-mode
+#+END_SRC
+
+Then compile the lisp files and generate the manuals,
+
+#+BEGIN_SRC sh
+$ make
+#+END_SRC
+
+Finally to have Emacs detect your Git version of nix-mode, you add the
+following your ~/.emacs.d/init.el configuration,
+
+#+BEGIN_SRC emacs-lisp
+(add-to-list 'load-path "~/.emacs.d/site-lisp/nix-mode/")
+
+(with-eval-after-load 'info
+ (info-initialize)
+ (add-to-list 'Info-directory-list
+ "~/.emacs.d/site-lisp/nix-mode/"))
+#+END_SRC
+
+** Configuration
+
+Users can install & configure nix-mode through use-package. Here is a
+recommended configuration,
+
+#+BEGIN_SRC emacs-lisp
+ (use-package nix-mode
+ :mode ("\\.nix\\'" "\\.nix.in\\'"))
+ (use-package nix-drv-mode
+ :ensure nix-mode
+ :mode "\\.drv\\'")
+ (use-package nix-shell
+ :ensure nix-mode
+ :commands (nix-shell-unpack nix-shell-configure nix-shell-build))
+ (use-package nix-repl
+ :ensure nix-mode
+ :commands (nix-repl))
+#+END_SRC
+
+You can also use the traditional require usage, but use-package
+provides many useful helpers for our purposes. In the next sections,
+some of the things provided will be explained
+
+** Modes
+
+*** nix-mode
+
+This is a major mode for editing Nix expressons. It provides syntax
+highlighting, sane defaults, and experimental indentation support.
+
+You can set it up to handle .nix files with,
+
+#+BEGIN_SRC emacs-lisp
+ (use-package nix-mode
+ :mode ("\\.nix\\'" "\\.nix.in\\'"))
+#+END_SRC
+
+To turn on the experimental “electric” style Nix indent, you have to
+set the custom variable, nix-indent-function. This can be set by
+typing,
+
+#+BEGIN_SRC text
+M-x customize-variable RET nix-indent-function RET
+#+END_SRC
+
+To set it to the experimental indentation, set this value to the
+function, nix-indent-line. Note that there are major bugs that
+prevents this from becoming the default. Certain kinds of code
+involving lots of hanging indents will be incorrect. But, we welcome
+attempts to improve this experience! Please submit pull requests at
+https://github.com/NixOS/nix-mode/pulls.
+
+*** nix-drv-mode
+
+nix-drv-mode is a simple major mode for viewing Nix’s .drv files. If
+you have use-package installed, you can set it up to handle .drv files
+with this in your configuration file,
+
+#+BEGIN_SRC emacs-lisp
+ (use-package nix-drv-mode
+ :ensure nix-mode
+ :mode "\\.drv\\'")
+#+END_SRC
+
+nix-drv-mode works by running “nix show-derivation” and showing you
+the prettified .json file produced.
+
+*** nix-repl
+
+nix-repl.el has two purposes. First, it provides an interface for
+completion, used by nix-company.el. Second, it provides an interactive
+function to open an repl. You can open this with:
+
+#+BEGIN_SRC text
+M-x nix-repl<RET>
+#+END_SRC
+
+This is the same prompt you would get from running “nix repl” on the
+command line. A recommended configuration is provided below,
+
+#+BEGIN_SRC emacs-lisp
+ (use-package nix-repl
+ :ensure nix-mode
+ :commands (nix-repl))
+#+END_SRC
+
+*** nix-shell
+
+nix-shell provides a few interactive commands to make it easier to
+make calls to nix-shell from Emacs. Recommended configuration is
+provided below.
+
+#+BEGIN_SRC emacs-lisp
+ (use-package nix-shell
+ :ensure nix-mode
+ :commands (nix-shell-unpack nix-shell-configure nix-shell-build))
+#+END_SRC
+
+First, there are 3 commands that run Nix phases for you.
+
+- nix-shell-unpack
+- nix-shell-configure
+- nix-shell-build
+
+You can run any one of these to invode the correspond Nix phase. For
+instance to unpack the source for Emacs, let’s start from a dired
+buffer,
+
+#+BEGIN_SRC text
+C-x C-f ~ RET
+#+END_SRC
+
+#+BEGIN_SRC text
+M-x nix-shell-unpack RET emacs RET
+#+END_SRC
+
+This will unpack the Emacs soure code. It may take a minute or two to
+unpack. After that, we can enter the Emacs directory with find-file,
+
+#+BEGIN_SRC text
+C-x C-f emacs-26.1 RET
+#+END_SRC
+
+Now that we are in the Emacs directory, we can run the configure
+scripts. This is as simple as,
+
+#+BEGIN_SRC text
+M-x nix-shell-configure RET <nixpkgs> RET emacs RET
+#+END_SRC
+
+This, again, will take a few minutes. After that, though, we can build
+
+#+BEGIN_SRC text
+M-x nix-shell-build RET <nixpkgs> RET emacs RET
+#+END_SRC
+
+If you want to avoid entering your Nix files and attributes again and
+again, you can set the values automatically through dir-locals.el.
+Still in the Emacs directory, run the following two commands,
+
+#+BEGIN_SRC text
+M-x add-dir-local-variable RET nil RET nix-file RET "<nixpkgs>" RET
+M-x add-dir-local-variable RET nil RET nix-attr RET "emacs" RET
+#+END_SRC
+
+*** nix.el
+
+nix.el also provides some basic functions for interfacing with Nix.
+Some variables are provided to point to the Nix binaries that can be
+used in Lisp code:
+
+- nix-executable
+- nix-build-executable
+- nix-instantiate-executable
+- nix-store-executable
+- nix-shell-executable
+
+Other useful functions for Lisp scripts are provided as well:
+
+- nix-system - Get the current system, detected by Nix
+
+*** Miscellaneous
+
+There are a few more Emacs Lisp files provided in nix-mode that have
+not been explained here. They are mostly experimental. We always
+welcome more contributions from interested developers.
+
+** Customization
+
+** Origins
+
+This repository is based off of the nix-mode.el file originally
+located in the [[https://github.com/NixOS/nix][Nix repository]] at
[[https://github.com/NixOS/nix/blob/master/misc/emacs/nix-mode.el][misc/emacs/nix-mode.el]].
+
+** Changelog
+
+Please see [[https://github.com/NixOS/nix-mode/blob/master/CHANGELOG.md][the
CHANGELOG file]] a list of changes.
+
+** Other Emacs packages
+
+@shlevy has an excellent package for integrating nix-shell into emacs.
+It is available at [[https://github.com/shlevy/nix-buffer][shlevy/nix-buffer]].
+
+@travisbhartwell also has some package dealing with Nix. They are
+available at
[[https://github.com/travisbhartwell/nix-emacs][travisbhartwell/nix-emacs]].
diff --git a/nix-repl.el b/nix-repl.el
index e8962806cd..79eeb78d03 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)
@@ -40,7 +37,8 @@
(set-process-filter ,proc proc-filter-saved)
(kill-buffer buf))))
-(defun nix-repl-show ()
+;;;###autoload
+(defun nix-repl ()
"Load the Nix-REPL."
(interactive)
(pop-to-buffer-same-window
@@ -49,11 +47,13 @@
(nix--make-repl-in-buffer (current-buffer))
(nix-repl-mode)))
+(defalias 'nix-repl-show 'nix-repl)
+
(defun nix--make-repl-in-buffer (buffer)
"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-search.el b/nix-search.el
new file mode 100644
index 0000000000..e60e16923e
--- /dev/null
+++ b/nix-search.el
@@ -0,0 +1,60 @@
+;;; nix-search.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:
+
+;;; Code:
+
+(require 'nix)
+(require 'json)
+
+;;;###autoload
+(defun nix-search (&optional search nix-file)
+ "Run nix search.
+SEARCH a search term to use.
+NIX-FILE a Nix expression to search in."
+ (interactive)
+ (unless search (setq search ""))
+ (unless nix-file (setq nix-file "<nixpkgs>"))
+ (let ((stdout (generate-new-buffer "nix search"))
+ result)
+ (call-process nix-executable nil (list stdout nil) nil
+ "search" "--json" "-f" nix-file search)
+ (with-current-buffer stdout
+ (when (eq (buffer-size) 0)
+ (error "Error: nix search %s failed to produce any output" search))
+ (goto-char (point-min))
+ (setq result (json-read)))
+ (kill-buffer stdout)
+ (when (called-interactively-p 'any)
+ (let ((display (generate-new-buffer "*nix search*")))
+ (with-current-buffer display
+ (dolist (entry result)
+ (widget-insert
+ (format "name: %s\nversion: %s\ndescription: %s\n\n"
+ (alist-get 'pkgName (cdr entry))
+ (alist-get 'version (cdr entry))
+ (alist-get 'description (cdr entry)))))
+ )
+ (display-buffer display 'display-buffer-pop-up-window)))
+ (kill-buffer stdout)
+ result))
+
+(defun nix-search-read-attr (nix-file)
+ "Read from a list of attributes.
+NIX-FILE the nix file to look in."
+ (let ((collection
+ (sort (mapcar (lambda (x) (symbol-name (car x)))
+ (nix-search "" nix-file))
+ 'string<))
+ (read (cond ((fboundp 'ivy-read) 'ivy-read)
+ (t 'completing-read))))
+ (funcall read "Attribute: " collection)))
+
+(provide 'nix-search)
+;;; nix-search.el ends here
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-haskell.el b/nix-shell-haskell.el
new file mode 100644
index 0000000000..01e56c21c0
--- /dev/null
+++ b/nix-shell-haskell.el
@@ -0,0 +1,107 @@
+;;; nix-shell-haskell.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:
+
+;; You can use nix-shell-haskell as a hook to haskell-mode.
+;; Just run:
+
+;; (require 'nix-shell-haskell)
+;; (add-hook 'haskell-mode 'nix-shell-haskell)
+
+;;; Code:
+
+(require 'nix)
+(require 'nix-instantiate)
+(require 'nix-shell)
+(require 'haskell)
+(require 'haskell-cabal)
+(require 'haskell-session)
+(require 'flycheck)
+
+(defun nix-shell-haskell--callback (buffer cabal-file drv &rest _)
+ "Run the nix-shell callback to setup the buffer.
+The BUFFER to run in.
+The CABAL-FILE to load from.
+The DRV file to use."
+ (let* ((env (alist-get 'env drv))
+ (stdenv (alist-get 'stdenv env))
+ (system (alist-get 'system env))
+ (inputs (remove nil
+ (apply 'append
+ (mapcar (lambda (prop)
+ (split-string (alist-get prop env)))
+ nix-shell-inputs)))))
+
+ ;; Prevent accidentally rebuilding the world.
+ (unless (file-directory-p stdenv)
+ (error
+ "Your stdenv at %s has not been built. Please run: nix-store -r %s"
+ stdenv stdenv))
+
+ ;; Make sure this .drv file can actually be built here.
+ (unless (string= system (nix-system))
+ (error
+ "Your system (%s) does not match .drv’s build system (%s)"
+ (nix-system) system))
+
+ (with-current-buffer buffer
+ (make-local-variable 'exec-path)
+
+ (dolist (input inputs)
+ (when (and (not (file-directory-p input))
+ nix-shell-auto-realise)
+ (nix-store-realise input))
+
+ (add-to-list 'exec-path (expand-file-name "bin" input)))
+
+ (when flycheck-mode
+ (flycheck-buffer)))
+
+ (when (and (eq major-mode 'haskell-mode) (not (haskell-session-maybe)))
+ (message "here")
+ (unless (haskell-session-lookup cabal-file)
+ (let ((session (haskell-session-make cabal-file)))
+ (haskell-session-set-cabal-dir (file-name-directory cabal-file))
+ (haskell-process-start session)))
+ (haskell-session-assign cabal-file))))
+
+;;;###autoload
+(defun nix-shell-haskell (&optional cabal-file)
+ "Setup Nix shell from the .cabal file."
+ (interactive)
+ (unless cabal-file
+ (setq cabal-file (haskell-cabal-find-file)))
+ (when (and (called-interactively-p) (not cabal-file))
+ (error "Cannot find a cabal file in %s" default-directory))
+ (when cabal-file
+ (setq cabal-file (expand-file-name cabal-file))
+ (let ((file (concat (file-name-sans-extension cabal-file) ".nix"))
+ (project-dir (locate-dominating-file cabal-file "default.nix")))
+ (with-temp-file file
+ (insert "let\n")
+ (insert (format " haskellPackages = %s.packages"
+ (if project-dir (format "(import %s {})"
+ (expand-file-name
+ "default.nix" project-dir))
+ "{}")))
+ (insert " or (import <nixpkgs> {}).haskellPackages;\n")
+ (insert "in\n")
+ (insert (format " (haskellPackages.callCabal2nix \"%s\" \"%s\" {}).env"
+ (file-name-base cabal-file) cabal-file))
+ (insert " .overrideAttrs (attrs: {\n")
+ (insert " nativeBuildInputs = (attrs.nativeBuildInputs or [])\n")
+ (insert " ++ (with haskellPackages; [
cabal-install ]);\n")
+ (insert " })\n"))
+ (nix-instantiate-async (apply-partially 'nix-shell-haskell--callback
+ (current-buffer)
+ cabal-file)
+ file))))
+
+(provide 'nix-shell-haskell)
+;;; nix-shell-haskell.el ends here
diff --git a/nix-shell.el b/nix-shell.el
index ca3dec72d2..61420a0bad 100644
--- a/nix-shell.el
+++ b/nix-shell.el
@@ -1,4 +1,4 @@
-;;; nix-shell.el -- run nix-shell in Emacs -*- lexical-binding: t -*-
+;;; nix-shell.el -- run nix commands in Emacs -*- lexical-binding: t -*-
;; Author: Matthew Bauer <mjbauer95@gmail.com>
;; Homepage: https://github.com/NixOS/nix-mode
@@ -16,44 +16,235 @@
;;; Code:
-;; (require 'nix-mode)
-(require 'term)
+(require 'nix)
+(require 'nix-instantiate)
+(require 'nix-store)
+(require 'nix-search)
(defgroup nix-shell nil
- "Customizations for nix-shell"
+ "All nix-shell options."
:group 'nix)
-(defcustom nix-shell-executable "nix-shell"
- "Location of ‘nix-shell’ executable."
- :group 'nix-shell
- :type 'string)
+(defcustom nix-shell-inputs '(depsBuildBuild
+ depsBuildBuildPropagated
+ nativeBuildInputs
+ propagatedNativeBuildInputs
+ depsBuildTarget
+ depsBuildTargetPropagated)
+ "List of inputs to collect for nix-shell."
+ :type 'list
+ :group 'nix-shell)
+
+(defcustom nix-shell-clear-environment nil
+ "Whether to clear the old ‘exec-path’ & environment.
+Similar to ‘--pure’ argument in command line nix-shell."
+ :type 'boolean
+ :group 'nix-shell)
+
+(defcustom nix-shell-auto-realise t
+ "Whether we can realise paths in the built .drv file."
+ :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 (path attribute)
- "Run ‘nix-shell’ in a terminal.
+(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 nix-file "<nixpkgs>")
+ (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: "))))
-PATH path containing Nix expressions.
-ATTRIBUTE attribute name in nixpkgs to use."
+;;;###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 (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*"))
+ (list (nix-shell--find-file)
+ (if nix-attr nix-attr (nix-search-read-attr "<nixpkgs>"))))
+ (nix-shell--run-phase "configure" file attr))
;;;###autoload
-(defun nix-unpack (path attribute)
+(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 (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)
"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.
+The DRV file to use."
+ (let* ((env (alist-get 'env drv))
+ (stdenv (alist-get 'stdenv env))
+ (system (alist-get 'system env))
+ (inputs (remove nil
+ (apply 'append
+ (mapcar (lambda (prop)
+ (split-string (alist-get prop env)))
+ nix-shell-inputs)))))
+
+ ;; Prevent accidentally rebuilding the world.
+ (unless (file-directory-p stdenv)
+ (error
+ "Your stdenv at %s has not been built. Please run: nix-store -r %s"
+ stdenv stdenv))
+
+ ;; Make sure this .drv file can actually be built here.
+ (unless (string= system (nix-system))
+ (error
+ "Your system (%s) does not match .drv’s build system (%s)"
+ (nix-system) system))
+
+ (with-current-buffer buffer
+ (when nix-shell-clear-environment
+ (setq-local exec-path nil)
+ (setq-local eshell-path-env "")
+ ;; (setq-local process-environment nil)
+ )
+
+ (dolist (input inputs)
+ (when (and (not (file-directory-p input))
+ nix-shell-auto-realise)
+ (nix-store-realise input))
+
+ (let ((bin (expand-file-name "bin" input))
+ (man (expand-file-name "share/man" input))
+ (include (expand-file-name "include" input)))
+ (add-to-list 'exec-path bin)
+ (setq-local eshell-path-env
+ (format "%s:%s" bin eshell-path-env))
+ (add-to-list 'woman-manpath man)
+ (add-to-list 'ffap-c-path include)
+ (add-to-list 'Man-header-file-path include)
+ (add-to-list 'irony-additional-clang-options
+ (format "-I%s" include))))
+
+ (when flycheck-mode
+ (flycheck-buffer))
+ )))
+
+(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.
+PKGS-FILE the Nix file to get the packages from."
+ (nix-instantiate-async (apply-partially 'nix-shell--callback
+ (current-buffer))
+ (nix-shell--with-packages-file packages pkgs-file)
+ ))
+
+(defun nix-shell--with-packages-file (packages &optional pkgs-file)
+ "Get a .nix file from the packages list.
+PACKAGES to put in the .nix file.
+PKGS-FILE package set to pull from."
+ (unless pkgs-file (setq pkgs-file "<nixpkgs>"))
+ (let ((nix-file (make-temp-file "nix-shell" nil ".nix")))
+ (with-temp-file nix-file
+ (insert (format "with import %s { };\n" pkgs-file))
+ (insert "runCommandCC \"shell\" {\n")
+ (insert " nativeBuildInputs = [\n")
+ (mapcar (lambda (x) (insert (format " %s\n" x))) packages)
+ (insert " ];\n")
+ (insert "} \"\"\n"))
+ nix-file))
+
+(defun nix-eshell-with-packages (packages &optional pkgs-file)
+ "Create an Eshell buffer that has the shell environment in it.
+PACKAGES a list of packages to pull in.
+PKGS-FILE a file to use to get the packages."
+ (let ((buffer (generate-new-buffer "*nix-eshell*")))
+ (pop-to-buffer-same-window buffer)
+
+ (setq-local nix-shell-clear-environment t)
+
+ (nix-shell--callback
+ (current-buffer)
+ (nix-instantiate
+ (nix-shell--with-packages-file packages pkgs-file)))
+
+ (eshell-mode)
+ buffer))
+
+(defun nix-eshell (file &optional attr)
+ "Create an Eshell buffer that has the shell environment in it.
+FILE the .nix expression to create a shell for.
+ATTR attribute to instantiate in NIX-FILE."
+ (interactive
+ (list
+ (if nix-file nix-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)
-PATH used for base of Nix expresions.
+ (setq-local nix-shell-clear-environment t)
-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)))
+ (nix-shell--callback
+ (current-buffer)
+ (nix-instantiate file attribute))
+
+ (eshell-mode)
+ buffer))
+
+;;;###autoload
+(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))
+ 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 nix-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-store.el b/nix-store.el
new file mode 100644
index 0000000000..c702f388d0
--- /dev/null
+++ b/nix-store.el
@@ -0,0 +1,25 @@
+;;; 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:
+
+;;; Code:
+
+(require 'nix)
+
+(defun nix-store-realise (path)
+ "Realise a path asynchronously.
+PATH the path within /nix/store to realise"
+ (make-process
+ :buffer nil
+ :command (list nix-store-executable "-r" path)
+ :noquery t
+ :name (format "*nix-store*<%s>" path)))
+
+(provide 'nix-store)
+;;; nix-store.el ends here
diff --git a/nix.el b/nix.el
new file mode 100644
index 0000000000..f6861da609
--- /dev/null
+++ b/nix.el
@@ -0,0 +1,278 @@
+;;; 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 'pcomplete)
+
+(defgroup nix nil
+ "Nix-related customizations"
+ :group 'languages)
+
+(defcustom nix-executable (executable-find "nix")
+ "Nix executable location."
+ :group 'nix
+ :type 'string)
+
+(defcustom nix-build-executable (executable-find "nix-build")
+ "Nix-build executable location."
+ :group 'nix
+ :type 'string)
+
+(defcustom nix-instantiate-executable (executable-find "nix-instantiate")
+ "Nix executable location."
+ :group 'nix
+ :type 'string)
+
+(defcustom nix-store-executable (executable-find "nix-store")
+ "Nix executable location."
+ :group 'nix
+ :type 'string)
+
+(defcustom nix-shell-executable (executable-find "nix-shell")
+ "Location of ‘nix-shell’ executable."
+ :group 'nix
+ :type 'string)
+
+(defun nix-system ()
+ "Get the current system tuple."
+ (let ((stdout (generate-new-buffer "nix eval"))
+ result)
+ (call-process nix-executable nil (list stdout nil) nil
+ "eval" "--raw" "(builtins.currentSystem)")
+ (with-current-buffer stdout (setq result (buffer-string)))
+ (kill-buffer stdout)
+ result))
+
+(defvar nix-commands
+ '("add-to-store"
+ "build"
+ "cat-nar"
+ "cat-store"
+ "copy"
+ "copy-sigs"
+ "dump-path"
+ "edit"
+ "eval"
+ "hash-file"
+ "hash-path"
+ "log"
+ "ls-nar"
+ "ls-store"
+ "optimise-store"
+ "path-info"
+ "ping-store"
+ "repl"
+ "run"
+ "search"
+ "show-config"
+ "show-derivation"
+ "sign-paths"
+ "to-base16"
+ "to-base32"
+ "to-base64"
+ "upgrade-nix"
+ "verify"
+ "why-depends"))
+
+(defvar nix-toplevel-options
+ '("-v"
+ "--verbose"
+ "-h"
+ "--help"
+ "--debug"
+ "--help-config"
+ "--option"
+ "--version"))
+
+(defvar nix-config-options
+ '("allowed-uris"
+ "allow-import-from-derivation"
+ "allow-new-priveleges"
+ "allowed-users"
+ "auto-optimise-store"
+ "builders"
+ "builders-use-substitutes"
+ "build-users-group"
+ "compress-build-log"
+ "connect-timeout"
+ "cores"
+ "extra-sandbox-paths"
+ "extra-substituters"
+ "fallback"
+ "fsync-metadata"
+ "hashed-mirrors"
+ "http-connections"
+ "keep-build-log"
+ "keep-derivations"
+ "keep-env-derivations"
+ "keep-outputs"
+ "max-build-log-size"
+ "max-jobs"
+ "max-silent-time"
+ "netrc-file"
+ "plugin-files"
+ "pre-build-hook"
+ "repeat"
+ "require-sigs"
+ "restrict-eval"
+ "sandbox"
+ "sandbox-dev-shm-size"
+ "sandbox-paths"
+ "secret-key-files"
+ "show-trace"
+ "substitute"
+ "substituters"
+ "system"
+ "timeout"
+ "trusted-public-keys"
+ "trusted-subtituters"
+ "trusted-users"))
+
+(defun nix--pcomplete-flags (options)
+ "Complete flags to the Nix command."
+ (while (pcomplete-match "^-" 0)
+ (pcomplete-here options)
+ (let ((last-arg (nth (1- pcomplete-index) pcomplete-args)))
+ (cond
+ ((string= "--option" last-arg)
+ (pcomplete-here nix-config-options)
+ (pcomplete-here))
+ ((or (string= "-f" last-arg) (string= "--file" last-arg))
+ (pcomplete-here (pcomplete-entries nil 'file-exists-p)))
+ ((or (string= "--arg" last-arg) (string= "--argstr" last-arg))
+ (pcomplete-here)
+ (pcomplete-here))
+ ((or (string= "-I" last-arg) (string= "--include" last-arg))
+ (pcomplete-here (pcomplete-entries nil 'file-exists-p)))
+ ((or (string= "-k" last-arg) (string= "--keep" last-arg))
+ (pcomplete-here))
+ ((or (string= "-u" last-arg) (string= "--unset" last-arg))
+ (pcomplete-here))
+ ((or (string= "-s" last-arg) (string= "--substituter" last-arg))
+ (pcomplete-here))))))
+
+;;;###autoload
+(defun pcomplete/nix ()
+ "Completion for the nix command."
+ (nix--pcomplete-flags nix-toplevel-options)
+ (pcomplete-here nix-commands)
+ (pcase (nth (1- pcomplete-index) pcomplete-args)
+ ("run"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr" "-c" "--command"
+ "-f" "--file" "-i" "-I" "--include"
+ "-k" "--keep" "-u" "--unset"))))
+ ("build"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr" "--dry-run"
+ "-f" "--file" "-I" "--include"
+ "--no-link" "-o" "--out-link"))))
+ ("add-to-store"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--dry-run" "-n" "--name"))))
+ ("copy"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--all" "--arg" "--argstr"
+ "-f" "--file" "--from"
+ "-I" "--include" "--no-check-sigs"
+ "--no-recursive" "-s" "--substitute"
+ "--to"))))
+ ("copy-sigs"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--all" "--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "-r" "--recursive" "-s"
"--substituter"))))
+ ("dump-path"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file" "-I" "--include"))))
+ ("edit"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file" "-I" "--include"))))
+ ("eval"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "--json" "--raw"))))
+ ("hash-file"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--base16" "--base32"
+ "--base64" "--type"))))
+ ("hash-path"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--base16" "--base32"
+ "--base64" "--type"))))
+ ("log"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "--json" "--raw"))))
+ ("ls-nar"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("-d" "--directory"
+ "--json" "-l" "--long"
+ "-R" "--recursive"))))
+ ("ls-store"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("-d" "--directory"
+ "--json" "-l" "--long"
+ "-R" "--recursive"))))
+ ("repl"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-I" "--include"))))
+ ("search"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file"
+ "-I" "--include"
+ "--json" "--no-cache"
+ "-u" "--update-cache"))))
+ ("show-config"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--json"))))
+ ("show-derivation"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file"
+ "-I" "--include"
+ "-r" "--recursive"))))
+ ("sign-paths"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--all" "--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "-k" "--key-file" "-r" "--recursive"))))
+ ("upgrade-nix"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("-p" "--profile"))))
+ ("verify"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--all" "--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "--no-contents" "--no-trust"
+ "-r" "--recursive" "-n" "--sigs-needed"
+ "-s" "--substuter"))))
+ ("why-depends"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("-a" "--all" "--arg" "--argstr"
+ "-f" "--file" "-I" "--include"))))
+ (_ (nix--pcomplete-flags nix-toplevel-options)))
+ (pcomplete-here (pcomplete-entries)))
+
+(provide 'nix)
+;;; nix.el ends here
- [nongnu] elpa/nix-mode 0181c35a4f 202/500: Add nix-unpack command., (continued)
- [nongnu] elpa/nix-mode 0181c35a4f 202/500: Add nix-unpack command., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0ac0271f6c 201/500: Update Homepage in .el files, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 39f29d8be4 207/500: Replace indentation code with simpler heuristics, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 57ac40d53b 214/500: Merge pull request #45 from eqyiel/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ba202b6657 220/500: Add nix-shell.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 082a25ba7d 227/500: Add more default packages in nix.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode b98c1083a0 234/500: nix-shell-file not risky, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 9fb4e16c9f 233/500: Setup global-nix-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 161e7ae4d2 237/500: Cleanup nix-instantiate, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode c1b1982ea7 239/500: Fix nix-instantiate.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1b15a6e583 252/500: Merge pull request #46 from matthewbauer/develop,
ELPA Syncer <=
- [nongnu] elpa/nix-mode 1e53bed4d4 299/500: Move the logic for indentation of first line of file, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 79a3715c3d 303/500: Improve handling of 'in' after a hanging 'let'., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 6e4f66de1d 317/500: Add all-packages.nix test case, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode f938aeaeb6 324/500: Fix buggy implementation of nix-smie--anchor., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 63fbbf27bf 326/500: Improve indentation of closing parentheses., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode b12aeada41 334/500: Don’t use smie-indent-line when nix-mode-use-smie is nil, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode e5abdd41e4 352/500: add json-mode dependency, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ab49f46754 027/500: Redo keymap, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 81e8c3dea6 032/500: cleanup formatting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 09d40e95e2 037/500: Skip braces with hanging indents, ELPA Syncer, 2022/01/29