-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
nix-log.el
39 lines (30 loc) · 1.06 KB
/
nix-log.el
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
33
34
35
36
37
38
39
;;; nix-log.el --- Run nix commands -*- lexical-binding: t -*-
;; Author: Matthew Bauer <[email protected]>
;; Homepage: https://github.com/NixOS/nix-mode
;; Keywords: nix
;; This file is NOT part of GNU Emacs.
;;; Commentary:
;;; Code:
(require 'nix)
(require 'nix-instantiate)
(require 'files)
(defun nix-log-path (drv-file)
"Get the nix log of path a derivation"
(let* ((drv-name (file-relative-name drv-file nix-store-dir))
(log-file (format "%s/log/nix/drvs/%s/%s.bz2"
nix-state-dir
(substring drv-name 0 2) (substring drv-name 2))))
(if (file-exists-p log-file) log-file
(error "No log is available for derivation"))))
;;;###autoload
(defun nix-log (file attr)
"Open the nix log.
FILE nix file to parse.
ATTR attribute to load the log of."
(interactive (list (nix-read-file) nil))
(unless attr (setq attr (nix-read-attr file)))
(let* ((drv-file (nix-instantiate file attr))
(log-file (nix-log-path drv-file)))
(find-file log-file)))
(provide 'nix-log)
;;; nix-log.el ends here