emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/nix-mode a6571fa877 260/500: Add nix-log.el


From: ELPA Syncer
Subject: [nongnu] elpa/nix-mode a6571fa877 260/500: Add nix-log.el
Date: Sat, 29 Jan 2022 08:27:12 -0500 (EST)

branch: elpa/nix-mode
commit a6571fa8773532aba4830dba892f4154193c317c
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>

    Add nix-log.el
---
 nix-log.el | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/nix-log.el b/nix-log.el
new file mode 100644
index 0000000000..8a9b40b7e5
--- /dev/null
+++ b/nix-log.el
@@ -0,0 +1,34 @@
+;;; nix-log.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)
+(require 'nix-instantiate)
+
+(defun nix-log (file attr)
+  "Open the nix log."
+  (interactive (list (nix-read-file) nil))
+  (unless attr (setq attr (nix-read-attr file)))
+
+  (let* ((drv-file (nix-instantiate file attr))
+         (drv-name (progn
+                     (string-match (format "^%s/\\(.*\\)$" nix-store-dir) 
drv-file)
+                     (match-string 1 drv-file)))
+         (log-file (format "%s/log/nix/drvs/%s/%s.bz2"
+                           nix-state-dir
+                           (substring drv-name 0 2) drv-name)))
+    (if (file-exists-p log-file)
+        (find-file log-file)
+      (error "No log is available for derivation"))))
+
+(provide 'nix-log)
+;;; nix-log.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]