aboutsummaryrefslogtreecommitdiff
path: root/emacs/guix-ui-generation.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/guix-ui-generation.el')
-rw-r--r--emacs/guix-ui-generation.el62
1 files changed, 42 insertions, 20 deletions
diff --git a/emacs/guix-ui-generation.el b/emacs/guix-ui-generation.el
index aa71645b4e..4047850f23 100644
--- a/emacs/guix-ui-generation.el
+++ b/emacs/guix-ui-generation.el
@@ -1,6 +1,6 @@
;;; guix-ui-generation.el --- Interface for displaying generations -*- lexical-binding: t -*-
-;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
+;; Copyright © 2014, 2015, 2016 Alex Kost <alezost@gmail.com>
;; This file is part of GNU Guix.
@@ -78,6 +78,18 @@ Each element from GENERATIONS is a generation number."
'switch-to-generation* profile generation)
operation-buffer)))
+(defun guix-system-generation? ()
+ "Return non-nil, if current generation is a system one."
+ (eq (guix-buffer-current-entry-type)
+ 'system-generation))
+
+(defun guix-generation-current-packages-profile (&optional generation)
+ "Return a directory where packages are installed for the
+current profile's GENERATION."
+ (guix-packages-profile (guix-ui-current-profile)
+ generation
+ (guix-system-generation?)))
+
;;; Generation 'info'
@@ -115,8 +127,9 @@ Each element from GENERATIONS is a generation number."
(lambda (btn)
(guix-buffer-get-display-entries
'list guix-package-list-type
- (list (guix-ui-current-profile)
- 'generation (button-get btn 'number))
+ (list (guix-generation-current-packages-profile
+ (button-get btn 'number))
+ 'installed)
'add))
"Show installed packages for this generation"
'number number)
@@ -190,8 +203,8 @@ VAL is a boolean value."
"List installed packages for the generation at point."
(interactive)
(guix-package-get-display
- (guix-ui-current-profile)
- 'generation (guix-list-current-id)))
+ (guix-generation-current-packages-profile (guix-list-current-id))
+ 'installed))
(defun guix-generation-list-generations-to-compare ()
"Return a sorted list of 2 marked generations for comparing."
@@ -200,6 +213,11 @@ VAL is a boolean value."
(user-error "2 generations should be marked for comparing")
(sort numbers #'<))))
+(defun guix-generation-list-profiles-to-compare ()
+ "Return a sorted list of 2 marked generation profiles for comparing."
+ (mapcar #'guix-generation-current-packages-profile
+ (guix-generation-list-generations-to-compare)))
+
(defun guix-generation-list-show-added-packages ()
"List package outputs added to the latest marked generation.
If 2 generations are marked with \\[guix-list-mark], display
@@ -209,8 +227,8 @@ installed in the other one."
(guix-buffer-get-display-entries
'list 'output
(cl-list* (guix-ui-current-profile)
- 'generation-diff
- (reverse (guix-generation-list-generations-to-compare)))
+ 'profile-diff
+ (reverse (guix-generation-list-profiles-to-compare)))
'add))
(defun guix-generation-list-show-removed-packages ()
@@ -222,8 +240,8 @@ installed in the other one."
(guix-buffer-get-display-entries
'list 'output
(cl-list* (guix-ui-current-profile)
- 'generation-diff
- (guix-generation-list-generations-to-compare))
+ 'profile-diff
+ (guix-generation-list-profiles-to-compare))
'add))
(defun guix-generation-list-compare (diff-fun gen-fun)
@@ -324,14 +342,13 @@ performance."
"Width of an output name \"column\".
This variable is used in auxiliary buffers for comparing generations.")
-(defun guix-generation-packages (profile generation)
- "Return a list of sorted packages installed in PROFILE's GENERATION.
+(defun guix-generation-packages (profile)
+ "Return a list of sorted packages installed in PROFILE.
Each element of the list is a list of the package specification
and its store path."
(let ((names+paths (guix-eval-read
(guix-make-guile-expression
- 'generation-package-specifications+paths
- profile generation))))
+ 'profile->specifications+paths profile))))
(sort names+paths
(lambda (a b)
(string< (car a) (car b))))))
@@ -360,8 +377,8 @@ Use the full PROFILE file name."
(indent-to guix-generation-output-name-width 2)
(insert path "\n"))
-(defun guix-generation-insert-packages (buffer profile generation)
- "Insert package outputs installed in PROFILE's GENERATION in BUFFER."
+(defun guix-generation-insert-packages (buffer profile)
+ "Insert package outputs installed in PROFILE in BUFFER."
(with-current-buffer buffer
(setq buffer-read-only nil
indent-tabs-mode nil)
@@ -369,9 +386,9 @@ Use the full PROFILE file name."
(mapc (lambda (name+path)
(guix-generation-insert-package
(car name+path) (cadr name+path)))
- (guix-generation-packages profile generation))))
+ (guix-generation-packages profile))))
-(defun guix-generation-packages-buffer (profile generation)
+(defun guix-generation-packages-buffer (profile generation &optional system?)
"Return buffer with package outputs installed in PROFILE's GENERATION.
Create the buffer if needed."
(let ((buf-name (guix-generation-packages-buffer-name
@@ -379,19 +396,24 @@ Create the buffer if needed."
(or (and (null guix-generation-packages-update-buffer)
(get-buffer buf-name))
(let ((buf (get-buffer-create buf-name)))
- (guix-generation-insert-packages buf profile generation)
+ (guix-generation-insert-packages
+ buf
+ (guix-packages-profile profile generation system?))
buf))))
(defun guix-profile-generation-manifest-file (generation)
"Return the file name of a GENERATION's manifest.
GENERATION is a generation number of the current profile."
- (guix-manifest-file (guix-ui-current-profile) generation))
+ (guix-manifest-file (guix-ui-current-profile)
+ generation
+ (guix-system-generation?)))
(defun guix-profile-generation-packages-buffer (generation)
"Insert GENERATION's package outputs in a buffer and return it.
GENERATION is a generation number of the current profile."
(guix-generation-packages-buffer (guix-ui-current-profile)
- generation))
+ generation
+ (guix-system-generation?)))
;;; Interactive commands