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

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

[nongnu] elpa/nix-mode 26928b8a20 2/7: Add `nix-store-show-log` to open


From: ELPA Syncer
Subject: [nongnu] elpa/nix-mode 26928b8a20 2/7: Add `nix-store-show-log` to open a log file from nix-store-path mode.
Date: Sun, 30 Oct 2022 19:58:58 -0400 (EDT)

branch: elpa/nix-mode
commit 26928b8a201c694be7ce376a1e591e21acf3587b
Author: zainab-ali <zainab@kebab-ca.se>
Commit: zainab-ali <zainab@kebab-ca.se>

    Add `nix-store-show-log` to open a log file from nix-store-path mode.
---
 README.md    |  5 ++++-
 nix-store.el | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index f3c2bd2ddd..3ef5662ced 100644
--- a/README.md
+++ b/README.md
@@ -93,9 +93,12 @@ overview of a store path. The information it shows is the 
realisation status,
 the hash and the size of the store path. Also it shows lists of derivers,
 references, referrers and requisites of the respective path.
 
-You can change the order in which that information is show. See the
+You can change the order in which that information is shown. See the
 documentation of the function `nix-store-show-path` for more information.
 
+When viewing a store buffer, the command `M-x nix-store-show-log`
+opens a local log file associated with a derivation.
+
 ### nix-prettify-mode.el
 
 When nix-prettify-mode is enabled, hash-parts of the Nix store file names are
diff --git a/nix-store.el b/nix-store.el
index d633031393..099019ecdc 100644
--- a/nix-store.el
+++ b/nix-store.el
@@ -206,6 +206,23 @@ It uses \\[nix-store-show-path] to display the store path."
   (interactive)
   (nix-store-show-path (nix-store-path-at-point)))
 
+(defun nix-store-show-log ()
+  "Opens the log file for the derivation of the nix-store path."
+  (interactive)
+  (let ((drv-name (when-let*
+                     ((drv-name (nix-store-path-derivers 
nix-buffer-store-path))
+                      (drv-name (car drv-name)))
+                   (file-relative-name drv-name nix-store-dir))))
+    (if (not drv-name)
+       (message "This store path has no associated derivation.")
+      (let ((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)
+            (find-file log-file)
+         (error "No log is available for derivation"))))))
+
 (defvar nix-store-path-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "RET") 'nix-store-show-path-at-point)



reply via email to

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