about summary refs log tree commit diff
path: root/configs/shared/emacs/.emacs.d/elpa/nix-mode-20180822.214/nix-build.el
blob: df85a676d6990c9a9e7113c8466bdb46271e0e9a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
;;; nix-build.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 'nix-search)

(defun nix-build (&optional file attr)
  "Run nix-build in a compilation buffer.
FILE the file to parse.
ATTR the attribute to build."
  (interactive (list (nix-read-file) nil))
  (unless attr (setq attr (nix-read-attr file)))

  (setq compile-command (format "%s %s -A '%s'" nix-build-executable
				file attr))
  (setq-default compilation-directory default-directory)
  (compilation-start compile-command nil
		     (apply-partially (lambda (attr _)
					(format "*nix-build*<%s>" attr))
				      attr)))

(provide 'nix-build)
;;; nix-build.el ends here