branch: elpa/nix-mode commit d9c1d4d4a4721857728dc2b9c7a44232cdd93f80 Author: Matthew Bauer <mjbaue...@gmail.com> Commit: Matthew Bauer <mjbaue...@gmail.com>
Remove maintained modes Most of these are maintained at travisbhartwell/nix-emacs --- misc/company-nixos-options.el | 75 ------------------------- misc/helm-nixos-options.el | 49 ---------------- misc/nix-sandbox.el | 127 ----------------------------------------- misc/nix.el | 43 -------------- misc/nixos-options.el | 128 ------------------------------------------ misc/nixos-packages.el | 115 ------------------------------------- nix-mode.el | 9 +++ 7 files changed, 9 insertions(+), 537 deletions(-) diff --git a/misc/company-nixos-options.el b/misc/company-nixos-options.el deleted file mode 100644 index d42cb30bb3..0000000000 --- a/misc/company-nixos-options.el +++ /dev/null @@ -1,75 +0,0 @@ -;;; company-nixos-options.el --- Company Backend for nixos-options - -;; Copyright (C) 2015 Diego Berrocal and Travis B. Hartwell - -;; Author: Diego Berrocal <cestdi...@gmail.com> -;; Travis B. Hartwell <na...@travishartwell.net> -;; Created: 18 July 2015 - -;; Keywords: unix -;; Homepage: http://www.github.com/travisbhartwell/nix-emacs/ -;; Version: 0.1.0 -;; Package-Requires: ((company "0.8.0") (nixos-options "0.0.1") (cl-lib "0.5.0")) - -;; This file is not part of GNU Emacs. - -;;; License: GPLv3 - -;;; Commentary: - -;; Useful functions for exploring the NixOS options. Inspired by -;; https://nixos.org/nixos/options.html. - -;;; Code: -(require 'nixos-options) -(require 'company) -(require 'cl-lib) - -(defun company-nixos-options--doc-buffer (candidate) - "Return documentation buffer for chosen CANDIDATE." - (let ((doc (nixos-options-get-documentation-for-option - (nixos-options-get-option-by-name candidate)))) - (and doc (nixos-options-doc-buffer doc)))) - -(defun company-nixos-options--candidates (prefix) - (let ((res)) - (dolist (option nixos-options) - (let ((name (nixos-options-get-name option))) - (when (string-prefix-p prefix name) - (push name res)))) - res)) - -(defun company-nixos-options--annotation (candidate) - (let ((type (nixos-options-get-type - (nixos-options-get-option-by-name - candidate)))) - (format " <%s>" type))) - -(defun company-nixos--grab-symbol () - (buffer-substring (point) (save-excursion (skip-syntax-backward "w_.") - (point)))) - -(defun company-nixos--in-nix-context-p () - (or (eq major-mode 'nix-mode) - (equal "nix" (file-name-extension - (buffer-file-name (current-buffer)))))) - -(defun company-nixos-options--prefix () - "Grab prefix at point." - (and (company-nixos--in-nix-context-p) - (or (company-nixos--grab-symbol) - 'stop))) - -;;;###autoload -(defun company-nixos-options (command &optional arg &rest ignored) - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-nixos-options)) - (prefix (company-nixos-options--prefix)) - (candidates (company-nixos-options--candidates arg)) - (doc-buffer (company-nixos-options--doc-buffer arg)) - (annotation (company-nixos-options--annotation arg)))) - -(provide 'company-nixos-options) -;;; company-nixos-options.el ends here - diff --git a/misc/helm-nixos-options.el b/misc/helm-nixos-options.el deleted file mode 100644 index 974274d425..0000000000 --- a/misc/helm-nixos-options.el +++ /dev/null @@ -1,49 +0,0 @@ -;;; helm-nixos-options.el --- Helm Interface for nixos-options - -;; Copyright (C) 2015 Diego Berrocal and Travis B. Hartwell - -;; Author: Diego Berrocal <cestdi...@gmail.com> -;; Travis B. Hartwell <na...@travishartwell.net> -;; Created: 18 July 2015 - -;; Keywords: unix -;; Homepage: http://www.github.com/travisbhartwell/nix-emacs/ -;; Version: 0.1.0 -;; Package-Requires: ((nixos-options "0.0.1") (helm "1.5.6")) - -;; This file is not part of GNU Emacs. - -;;; License: GPLv3 - -;;; Commentary: - -;; Useful functions for exploring the NixOS options. Inspired by -;; https://nixos.org/nixos/options.html. - -;;; Code: -(require 'nixos-options) -(require 'helm) - -(defun helm-source-nixos-options-search () - `((name . "NixOS Options") - (requires-pattern . 2) - (candidates . nixos-options) - (follow . 1) - (persistent-action . (lambda (f) (message (format "%s" (nixos-options-get-description f))))) - (action . (("View documentation" . (lambda (f) - (switch-to-buffer-other-window - (nixos-options-doc-buffer - (nixos-options-get-documentation-for-option f))))) - ("Insert into buffer" . (lambda (f) (insert (nixos-options-get-name f)))) - ("Pretty print" . (lambda (f) (message "Pretty Printed: %s" (pp f)))) - ("Display name" . (lambda (f) (message "Name: %s" (nixos-options-get-name f)))))))) - -;;;###autoload -(defun helm-nixos-options () - (interactive) - (helm :sources `(,(helm-source-nixos-options-search)) - :buffer "*helm-nixos-options*")) - -(provide 'helm-nixos-options) -;;; helm-nixos-options.el ends here - diff --git a/misc/nix-sandbox.el b/misc/nix-sandbox.el deleted file mode 100644 index 492a68d422..0000000000 --- a/misc/nix-sandbox.el +++ /dev/null @@ -1,127 +0,0 @@ -;;; nix-sandbox.el --- Utility functions to work with nix-shell sandboxes - -;; Copyright (C) 2015 Sven Keidel - -;; Author: Sven Keidel <svenkei...@gmail.com> -;; Package-Version: 0.1 -;; Package-Requires: ((dash "2.12.1") (s "1.10.0")) -;; Homepage: https://github.com/travisbhartwell/nix-emacs - -;; This file is not part of GNU Emacs. - -;;; License: GPLv3 - -;;; Commentary: - -;; Useful functions for working with nix-shell sandboxes - -;;; Code: - -(require 'dash) -(require 's) - -(defgroup nix nil - "customizations for nix" - :prefix "nix-" - :group 'external) - -(defcustom nix-nixpkgs-path nil - "Absolute path to a nixpkgs directory. - -Can be customized to select a nix-channel -e.g. /home/user/.nix-defexpr/channels/unstable/nixpkgs" - :group 'nix - :type '(choice (const :tag "No channel" nil) - (directory "Custom path to a nixpkgs distribution"))) - -(defun nix-create-sandbox-rc (sandbox) - "Create a new rc file containing the environment for the given SANDBOX." - (let ((env-str (shell-command-to-string - (concat "nix-shell " - (or (and nix-nixpkgs-path (concat "-I nixpkgs=" nix-nixpkgs-path)) - "") - " --run 'declare +x shellHook; declare -x; declare -xf' " - (shell-quote-argument sandbox) - " 2> /dev/null"))) - (tmp-file (make-temp-file "nix-sandbox-rc-"))) - (write-region env-str nil tmp-file 'append) - tmp-file)) - -(defvar nix-sandbox-rc-map (make-hash-table :test 'equal - :size 4)) - -(defun nix-sandbox-rc (sandbox) - "Return the rc file for the given SANDBOX or create one." - (or (gethash sandbox nix-sandbox-rc-map) - (puthash sandbox (nix-create-sandbox-rc sandbox) nix-sandbox-rc-map))) - -;;;###autoload -(defun nix-shell-command (sandbox &rest args) - "Assemble a command from ARGS that can be executed in the specified SANDBOX." - (list "bash" "-c" (format "source %s; %s" (nix-sandbox-rc sandbox) (s-join " " args)))) - -(defun nix-shell-string (sandbox &rest args) - "Assemble a command string from ARGS that can be executed in the specifed SANDBOX." - (combine-and-quote-strings - (apply 'nix-shell-command sandbox args))) - -;;;###autoload -(defun nix-compile (sandbox &rest command) - "Compile a program using the given COMMAND in SANDBOX." - (interactive "Dsandbox: \nMcommand: ") - (compile (apply 'nix-shell-string sandbox command))) - -;;;###autoload -(defun nix-shell (sandbox &rest command) - "Run a COMMAND in the given SANDBOX and return the output." - (shell-command-to-string (apply 'nix-shell-string sandbox command))) - -(defvar nix-exec-path-map (make-hash-table :test 'equal - :size 4)) - -;;;###autoload -(defun nix-exec-path (sandbox) - "Return the `exec-path' of the given SANDBOX." - - (or (gethash sandbox nix-exec-path-map) - (puthash sandbox - (split-string (nix-shell sandbox "printenv" "PATH") ":") - nix-exec-path-map))) - -;;;###autoload -(defun nix-executable-find (sandbox executable) - "Search for an EXECUTABLE in the given SANDBOX." - (let ((exec-path (nix-exec-path sandbox))) - (and exec-path (executable-find executable)))) - -;;;###autoload -(defun nix-find-sandbox (path) - "Search for a sandbox starting at PATH traversing upwards the directory tree. -If the directory contains a `shell.nix' file, the path to this -file is returned. Otherwise if the directory contains a -`default.nix' file, the parent directory is returned." - (and (file-exists-p path) - (let* ((map-nil (lambda (f x) (if x (funcall f x) nil))) - (sandbox-directory - (funcall map-nil 'expand-file-name - (locate-dominating-file path - '(lambda (dir) (directory-files dir t ".*\.nix$"))))) - (shell-nix (and sandbox-directory (concat sandbox-directory "shell.nix")))) - (if (and sandbox-directory (file-exists-p shell-nix)) - shell-nix - sandbox-directory)))) - -;;;###autoload -(defun nix-current-sandbox () - "Return the path of the sandbox that is closest to the current working directory." - (nix-find-sandbox default-directory)) - -(defun nix-clear-caches () - "Clear cached information for all sandboxes." - (interactive) - (clrhash nix-sandbox-rc-map) - (clrhash nix-exec-path-map)) - -(provide 'nix-sandbox) - -;;; nix-sandbox.el ends here diff --git a/misc/nix.el b/misc/nix.el deleted file mode 100644 index 8aa15ca9ec..0000000000 --- a/misc/nix.el +++ /dev/null @@ -1,43 +0,0 @@ -;;; help-vars.el --- Variables related to Guix --help output - -;; Copyright © 2015 Alex Kost <alez...@gmail.com> - -;; This file is part of Emacs-Guix. - -;; Emacs-Guix is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. -;; -;; Emacs-Guix is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with Emacs-Guix. If not, see <http://www.gnu.org/licenses/>. - -;;; Commentary: - -;; This file provides regular expressions to parse various "guix -;; ... --help" outputs and lists of non-receivable items (system types, -;; hash formats, etc.). - -;;; Code: - -(defgroup nix nil - "Interface for Nix package manager." - :prefix "nix-" - :group 'external) - -(defgroup nix-faces nil - "Nix faces." - :group 'nix - :group 'faces) - -(defvar nix-system-types - '("x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin") - "List of supported systems.") - -(provide 'nix) -;;; nix.el ends here diff --git a/misc/nixos-options.el b/misc/nixos-options.el deleted file mode 100644 index 89ace9bbc4..0000000000 --- a/misc/nixos-options.el +++ /dev/null @@ -1,128 +0,0 @@ -;;; nixos-options.el --- Interface for browsing and completing NixOS options. - -;; Copyright (C) 2015 Diego Berrocal and Travis B. Hartwell - -;; Author: Diego Berrocal <cestdi...@gmail.com> -;; Travis B. Hartwell <na...@travishartwell.net> -;; Created: 18 July 2015 - -;; Keywords: unix -;; Homepage: http://www.github.com/travisbhartwell/nix-emacs/ -;; Version: 0.0.1 -;; Package-Requires: ((emacs "24")) - -;; This file is not part of GNU Emacs. - -;;; License: GPLv3 - -;;; Commentary: - -;; Useful functions for exploring the NixOS options. Inspired by -;; https://nixos.org/nixos/options.html. - -;;; Code: - -(require 'json) - -(defvar nixos-options-name-indent-amount 0 - "Indent by the maximum length, plus a colon, plus two spaces.") - -;; Macros for defining constants and functions for working with options -(defmacro define-nixos-options-item (item long-name) - (let* ((name-const (intern (concat "nixos-options-" item))) - (long-name-const (intern (concat "nixos-options-" item "-long-name"))) - (long-name-length-plus-padding (+ 3 (length long-name))) - (long-name-docstring (format "The long description for %s." item)) - (item-getter (intern (concat "nixos-options-get-" item))) - (item-getter-docstring - (format "Get the value of %s from OPTION." item)) - (item-display (intern (concat "nixos-options-display-" item))) - (item-display-docstring - (format "Display the value for %s from OPTION." item))) - `(progn - (defconst ,name-const ,item) - (defconst ,long-name-const ,long-name ,long-name-docstring) - (if (> ,long-name-length-plus-padding nixos-options-name-indent-amount) - (setq nixos-options-name-indent-amount - ,long-name-length-plus-padding)) - (defun ,item-getter (option) - ,item-getter-docstring - (cdr (assoc ,name-const option))) - (defun ,item-display (option) - ,item-display-docstring - (let ((item (,item-getter option)) - (format-string - (format "%%-%ds %%s\n" nixos-options-name-indent-amount))) - (if (not (null item)) - (format format-string (concat ,long-name-const ":") item) - "")))))) - -(define-nixos-options-item "name" "Name") -(define-nixos-options-item "type" "Type") -(define-nixos-options-item "description" "Description") -(define-nixos-options-item "default" "Default value") -(define-nixos-options-item "example" "Example value") -(define-nixos-options-item "declarations" "Declared in") - -(defvar nixos-options-json-file - (let* ((cmd - "export NIXPKGS_ALLOW_UNFREE=1; nix-build -Q --no-out-link '<nixpkgs/nixos/release.nix>' -A options 2>/dev/null") - (dir (replace-regexp-in-string "\n\\'" "" - (shell-command-to-string cmd)))) - (expand-file-name "share/doc/nixos/options.json" dir)) - "Location of the options file.") - -(defun nixos-options--boolean-string (value) - "Return the string representation of the boolean VALUE. -Returns VALUE unchanged if not a boolean." - (cond ((eq value 't) "true") - ((eq value :json-false) "false") - (t value))) - -(defun nixos-options--make-alist (option) - (let ((name (car option)) - (data (cdr option)) - (default (nixos-options-get-default option)) - (example (nixos-options-get-example option))) - (progn - (if (not (null default)) - (setcdr (assoc nixos-options-default option) - (nixos-options--boolean-string default))) - (if (not (null example)) - (setcdr (assoc nixos-options-example option) - (nixos-options--boolean-string example))) - (add-to-list 'data `(,nixos-options-name . ,name)) - `(,name . ,data)))) - -(defvar nixos-options - (if (file-exists-p nixos-options-json-file) - (let* ((json-key-type 'string) - (raw-options (json-read-file nixos-options-json-file))) - (mapcar 'nixos-options--make-alist raw-options)) - (message "Warning: Cannot find nixos option file."))) - -(defun nixos-options-get-documentation-for-option (option) - (concat (nixos-options-display-name option) - (nixos-options-display-type option) - (nixos-options-display-description option) - (nixos-options-display-default option) - (nixos-options-display-example option) - (nixos-options-display-declarations option))) - -;; Borrowed from anaconda-mode -(defun nixos-options-doc-buffer (doc) - "Display documentation buffer with contents DOC." - (let ((buf (get-buffer-create "*nixos-options-doc*"))) - (with-current-buffer buf - (view-mode -1) - (erase-buffer) - (insert doc) - (goto-char (point-min)) - (view-mode 1) - buf))) - -(defun nixos-options-get-option-by-name (name) - (assoc name nixos-options)) - -(provide 'nixos-options) -;;; nixos-options.el ends here diff --git a/misc/nixos-packages.el b/misc/nixos-packages.el deleted file mode 100644 index bc21c4e3e4..0000000000 --- a/misc/nixos-packages.el +++ /dev/null @@ -1,115 +0,0 @@ -;;; nixos-packages.el --- Interface for browsing and completing NixOS packages. - -;; Copyright (C) 2015 Diego Berrocal and Travis B. Hartwell - -;; Author: Diego Berrocal <cestdi...@gmail.com> -;; Travis B. Hartwell <na...@travishartwell.net> -;; Created: 18 July 2015 - -;; Keywords: unix -;; Homepage: http://www.github.com/travisbhartwell/nix-emacs/ -;; Version: 0.0.1 -;; Package-Requires: ((emacs "24")) - -;; This file is not part of GNU Emacs. - -;;; License: GPLv3 - -;;; Commentary: - -;; Useful functions for exploring the NixOS packages. Inspired by -;; https://nixos.org/nixos/packages.html. - -;;; Code: - -(require 'json) - -(defvar nixos-packages-json-file - (expand-file-name "nixos-packages.json" spacemacs-cache-directory) - "Where to store the nixos-packages in JSON format") - -(defvar nixos-packages-name-indent-amount 0 - "Indent by the maximum length, plus a colon, plus two spaces.") - -(setq nixos-packages - (if (file-exists-p nixos-packages-json-file) - (let ((json-key-type 'string)) - (json-read-file nixos-packages-json-file)) - (let* ((cmd "nix-env -qaP hello --json") - (data (replace-regexp-in-string "\n\\'" "" - (shell-command-to-string cmd))) - (json-key-type 'string)) - (append-to-file data nil nixos-packages-json-file) - (json-read-from-string data)))) - - -(assoc "name" (car nixos-packages)) -(assoc "system" (car nixos-packages)) -(assoc "description" (assoc "meta" (car nixos-packages))) -(assoc "homepage" (assoc "meta" (car nixos-packages))) -(assoc "license" (assoc "meta" (car nixos-packages))) -(assoc "longDescription" (assoc "meta" (car nixos-packages))) -(assoc "platforms" (assoc "meta" (car nixos-packages))) -(assoc "position" (assoc "meta" (car nixos-packages))) -(assoc "maintainers" (assoc "meta" (car nixos-packages))) -(assoc "maintainers" (assoc "meta" (car nixos-packages))) - -;; Macros for defining constants and functions for working with options -(defmacro define-nixos-packages-item (item long-name &optional isMeta?) - (let* ((name-const (intern (concat "nixos-packages-" item))) - (long-name-const (intern (concat "nixos-packages-" item "-long-name"))) - (long-name-length-plus-padding (+ 3 (length long-name))) - (long-name-docstring (format "The long description for %s." item)) - (item-getter (intern (concat "nixos-packages-get-" item))) - (item-getter-docstring - (format "Get the value of %s from PACKAGE" item)) - (item-display (intern (concat "nixos-packages-display-" item))) - (item-display-docstring - (format "Display the value for %s from PACKAGE" item))) - `(progn - (defconst ,name-const ,item) - (defconst ,long-name-const ,long-name ,long-name-docstring) - (if (> ,long-name-length-plus-padding nixos-packages-name-indent-amount) - (setq nixos-packages-name-indent-amount - ,long-name-length-plus-padding)) - (if ,isMeta? - (defun ,item-getter (option) - ,item-getter-docstring - (cdr (assoc ,name-const (assoc "meta" option)))) - (defun ,item-getter (option) - ,item-getter-docstring - (cdr (assoc ,name-const option)))) - - (defun ,item-display (option) - ,item-display-docstring - (let ((item (,item-getter option)) - (format-string - (format "%%-%ds %%s\n" nixos-packages-name-indent-amount))) - (if (not (null item)) - (format format-string (concat ,long-name-const ":") item) - "")))))) - -(define-nixos-packages-item "description" "Description" t) -(define-nixos-packages-item "homepage" "Home Page URL" t) -(define-nixos-packages-item "license" "License" t) -(define-nixos-packages-item "longDescription" "Long Description" t) -(define-nixos-packages-item "platforms" "Supported Platforms" t) -(define-nixos-packages-item "maintainers" "List of Maintainers" t) -(define-nixos-packages-item "position" "Path to the nix-expression with line" t) -(define-nixos-packages-item "name" "Name") -(define-nixos-packages-item "system" "System") - -(defun nixos-packages--make-alist (package) - (let ((name (car package)) - (data (cdr package)) - (default (nixos-options-get-default package)) - (example (nixos-options-get-example package))) - (progn - (if (not (null default)) - (setcdr (assoc nixos-options-default package) - (nixos-options--boolean-string default))) - (if (not (null example)) - (setcdr (assoc nixos-options-example package) - (nixos-options--boolean-string example))) - (add-to-list 'data `(,nixos-options-name . ,name)) - `(,name . ,data)))) diff --git a/nix-mode.el b/nix-mode.el index c6f31c6e3c..c99f56d429 100644 --- a/nix-mode.el +++ b/nix-mode.el @@ -31,6 +31,15 @@ "Nix mode customizations" :group 'nix) +(defgroup nix-faces nil + "Nix faces." + :group 'nix + :group 'faces) + +(defvar nix-system-types + '("x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin") + "List of supported systems.") + ;;; Syntax coloring (defconst nix-keywords