From: Alex Kost <alezost@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH 3/6] emacs: Find packages in system profiles.
Date: Sun, 10 Jan 2016 12:53:47 +0300 [thread overview]
Message-ID: <1452419630-4399-4-git-send-email-alezost@gmail.com> (raw)
In-Reply-To: <1452419630-4399-1-git-send-email-alezost@gmail.com>
For a usual profile, packages are placed in a profile directory itself,
but for a system profile, packages are placed in 'profile'
sub-directory. So we need to do some special cases for system profiles
to find packages there as well.
* emacs/guix-base.el (guix-packages-profile): New procedure.
(guix-manifest-file): Use it. Add optional 'system?' argument.
* emacs/guix-ui-generation.el (guix-system-generation?)
(guix-generation-current-packages-profile): New procedures.
(guix-generation-packages, guix-generation-insert-packages)
(guix-generation-packages-buffer): Add optional 'system?' argument.
(guix-profile-generation-manifest-file)
(guix-profile-generation-packages-buffer): Adjust accordingly.
* emacs/guix-main.scm (generation-package-specifications+paths): Rename to...
(profile->specifications+paths): ... this. Use a single 'profile' argument.
---
emacs/guix-base.el | 25 ++++++++++++++++++-------
emacs/guix-main.scm | 9 ++++-----
emacs/guix-ui-generation.el | 36 ++++++++++++++++++++++++++----------
3 files changed, 48 insertions(+), 22 deletions(-)
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index dae658e..d720a87 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -1,6 +1,6 @@
;;; guix-base.el --- Common definitions -*- 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.
@@ -91,14 +91,25 @@ For the meaning of location, see `guix-find-location'."
"Return the file name of a PROFILE's GENERATION."
(format "%s-%s-link" profile generation))
-(defun guix-manifest-file (profile &optional generation)
+(defun guix-packages-profile (profile &optional generation system?)
+ "Return a directory where packages are installed for the
+PROFILE's GENERATION.
+
+If SYSTEM? is non-nil, then PROFILE is considered to be a system
+profile. Unlike usual profiles, for a system profile, packages
+are placed in 'profile' subdirectory."
+ (let ((profile (if generation
+ (guix-generation-file profile generation)
+ profile)))
+ (if system?
+ (expand-file-name "profile" profile)
+ profile)))
+
+(defun guix-manifest-file (profile &optional generation system?)
"Return the file name of a PROFILE's manifest.
-If GENERATION number is specified, return manifest file name for
-this generation."
+See `guix-packages-profile'."
(expand-file-name "manifest"
- (if generation
- (guix-generation-file profile generation)
- profile)))
+ (guix-packages-profile profile generation system?)))
;;;###autoload
(defun guix-edit (id-or-name)
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index 8c38e7c..5460c96 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2014, 2015, 2016 Alex Kost <alezost@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -144,11 +144,10 @@ return two values: name and version. For example, for SPEC
(manifest-entries->package-specifications
(manifest-entries manifest))))
-(define (generation-package-specifications+paths profile number)
- "Return a list of package specifications and paths for generation NUMBER.
+(define (profile->specifications+paths profile)
+ "Return a list of package specifications and paths for PROFILE.
Each element of the list is a list of the package specification and its path."
- (let ((manifest (profile-manifest
- (generation-file-name profile number))))
+ (let ((manifest (profile-manifest profile)))
(map (lambda (entry)
(list (manifest-entry->package-specification entry)
(manifest-entry-item entry)))
diff --git a/emacs/guix-ui-generation.el b/emacs/guix-ui-generation.el
index aa71645..cb32e04 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?)))
+
\f
;;; Generation 'info'
@@ -324,14 +336,14 @@ performance."
"Width of an output name \"column\".
This variable is used in auxiliary buffers for comparing generations.")
-(defun guix-generation-packages (profile generation)
+(defun guix-generation-packages (profile generation &optional system?)
"Return a list of sorted packages installed in PROFILE's GENERATION.
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
+ (guix-packages-profile profile generation system?)))))
(sort names+paths
(lambda (a b)
(string< (car a) (car b))))))
@@ -360,7 +372,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)
+(defun guix-generation-insert-packages (buffer profile generation
+ &optional system?)
"Insert package outputs installed in PROFILE's GENERATION in BUFFER."
(with-current-buffer buffer
(setq buffer-read-only nil
@@ -369,9 +382,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 generation system?))))
-(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 +392,22 @@ 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 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?)))
\f
;;; Interactive commands
--
2.6.3
next prev parent reply other threads:[~2016-01-10 9:54 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-10 9:53 [PATCH 0/6] emacs: Add "M-x guix-system-generations" Alex Kost
2016-01-10 9:53 ` [PATCH 1/6] guix system: Export <boot-parameters> accessors Alex Kost
2016-01-12 20:25 ` Ludovic Courtès
2016-01-13 20:44 ` Alex Kost
2016-01-13 22:33 ` Ludovic Courtès
2016-01-14 8:34 ` Alex Kost
2016-01-14 13:25 ` Ludovic Courtès
2016-01-10 9:53 ` [PATCH 2/6] emacs: profiles: Add 'guix-system-profile' Alex Kost
2016-01-12 20:25 ` Ludovic Courtès
2016-01-10 9:53 ` Alex Kost [this message]
2016-01-12 20:28 ` [PATCH 3/6] emacs: Find packages in system profiles Ludovic Courtès
2016-01-13 20:45 ` Alex Kost
2016-01-13 22:42 ` Ludovic Courtès
2016-01-14 8:38 ` Alex Kost
2016-01-14 13:27 ` Ludovic Courtès
2016-01-10 9:53 ` [PATCH 4/6] emacs: Replace 'generation-diff' search with 'profile-diff' Alex Kost
2016-01-12 20:29 ` Ludovic Courtès
2016-01-10 9:53 ` [PATCH 5/6] emacs: Remove 'generation' search type Alex Kost
2016-01-12 20:31 ` Ludovic Courtès
2016-01-10 9:53 ` [PATCH 6/6] emacs: Add interface for system generations Alex Kost
2016-01-12 20:35 ` Ludovic Courtès
2016-01-13 20:56 ` Alex Kost
2016-01-13 22:44 ` Ludovic Courtès
2016-01-12 20:23 ` [PATCH 0/6] emacs: Add "M-x guix-system-generations" Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1452419630-4399-4-git-send-email-alezost@gmail.com \
--to=alezost@gmail.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.