Skip to content
Snippets Groups Projects
Commit 2df17bd0 authored by Alex Kost's avatar Alex Kost
Browse files

emacs: Find packages in system profiles.

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): Remove
  'generation' argument.
  (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.
parent a0ad8ab0
No related branches found
No related tags found
No related merge requests found
;;; guix-base.el --- Common definitions -*- lexical-binding: t -*- ;;; 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. ;; This file is part of GNU Guix.
...@@ -91,14 +91,25 @@ For the meaning of location, see `guix-find-location'." ...@@ -91,14 +91,25 @@ For the meaning of location, see `guix-find-location'."
"Return the file name of a PROFILE's GENERATION." "Return the file name of a PROFILE's GENERATION."
(format "%s-%s-link" profile 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. "Return the file name of a PROFILE's manifest.
If GENERATION number is specified, return manifest file name for See `guix-packages-profile'."
this generation."
(expand-file-name "manifest" (expand-file-name "manifest"
(if generation (guix-packages-profile profile generation system?)))
(guix-generation-file profile generation)
profile)))
;;;###autoload ;;;###autoload
(defun guix-edit (id-or-name) (defun guix-edit (id-or-name)
......
;;; GNU Guix --- Functional package management for GNU ;;; 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. ;;; This file is part of GNU Guix.
;;; ;;;
...@@ -144,11 +144,10 @@ (define (generation-package-specifications profile number) ...@@ -144,11 +144,10 @@ (define (generation-package-specifications profile number)
(manifest-entries->package-specifications (manifest-entries->package-specifications
(manifest-entries manifest)))) (manifest-entries manifest))))
(define (generation-package-specifications+paths profile number) (define (profile->specifications+paths profile)
"Return a list of package specifications and paths for generation NUMBER. "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." Each element of the list is a list of the package specification and its path."
(let ((manifest (profile-manifest (let ((manifest (profile-manifest profile)))
(generation-file-name profile number))))
(map (lambda (entry) (map (lambda (entry)
(list (manifest-entry->package-specification entry) (list (manifest-entry->package-specification entry)
(manifest-entry-item entry))) (manifest-entry-item entry)))
......
;;; guix-ui-generation.el --- Interface for displaying generations -*- lexical-binding: t -*- ;;; 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. ;; This file is part of GNU Guix.
...@@ -78,6 +78,18 @@ Each element from GENERATIONS is a generation number." ...@@ -78,6 +78,18 @@ Each element from GENERATIONS is a generation number."
'switch-to-generation* profile generation) 'switch-to-generation* profile generation)
operation-buffer))) 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' ;;; Generation 'info'
...@@ -324,14 +336,13 @@ performance." ...@@ -324,14 +336,13 @@ performance."
"Width of an output name \"column\". "Width of an output name \"column\".
This variable is used in auxiliary buffers for comparing generations.") This variable is used in auxiliary buffers for comparing generations.")
(defun guix-generation-packages (profile generation) (defun guix-generation-packages (profile)
"Return a list of sorted packages installed in PROFILE's GENERATION. "Return a list of sorted packages installed in PROFILE.
Each element of the list is a list of the package specification Each element of the list is a list of the package specification
and its store path." and its store path."
(let ((names+paths (guix-eval-read (let ((names+paths (guix-eval-read
(guix-make-guile-expression (guix-make-guile-expression
'generation-package-specifications+paths 'profile->specifications+paths profile))))
profile generation))))
(sort names+paths (sort names+paths
(lambda (a b) (lambda (a b)
(string< (car a) (car b)))))) (string< (car a) (car b))))))
...@@ -360,8 +371,8 @@ Use the full PROFILE file name." ...@@ -360,8 +371,8 @@ Use the full PROFILE file name."
(indent-to guix-generation-output-name-width 2) (indent-to guix-generation-output-name-width 2)
(insert path "\n")) (insert path "\n"))
(defun guix-generation-insert-packages (buffer profile generation) (defun guix-generation-insert-packages (buffer profile)
"Insert package outputs installed in PROFILE's GENERATION in BUFFER." "Insert package outputs installed in PROFILE in BUFFER."
(with-current-buffer buffer (with-current-buffer buffer
(setq buffer-read-only nil (setq buffer-read-only nil
indent-tabs-mode nil) indent-tabs-mode nil)
...@@ -369,9 +380,9 @@ Use the full PROFILE file name." ...@@ -369,9 +380,9 @@ Use the full PROFILE file name."
(mapc (lambda (name+path) (mapc (lambda (name+path)
(guix-generation-insert-package (guix-generation-insert-package
(car name+path) (cadr name+path))) (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. "Return buffer with package outputs installed in PROFILE's GENERATION.
Create the buffer if needed." Create the buffer if needed."
(let ((buf-name (guix-generation-packages-buffer-name (let ((buf-name (guix-generation-packages-buffer-name
...@@ -379,19 +390,24 @@ Create the buffer if needed." ...@@ -379,19 +390,24 @@ Create the buffer if needed."
(or (and (null guix-generation-packages-update-buffer) (or (and (null guix-generation-packages-update-buffer)
(get-buffer buf-name)) (get-buffer buf-name))
(let ((buf (get-buffer-create 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)))) buf))))
(defun guix-profile-generation-manifest-file (generation) (defun guix-profile-generation-manifest-file (generation)
"Return the file name of a GENERATION's manifest. "Return the file name of a GENERATION's manifest.
GENERATION is a generation number of the current profile." 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) (defun guix-profile-generation-packages-buffer (generation)
"Insert GENERATION's package outputs in a buffer and return it. "Insert GENERATION's package outputs in a buffer and return it.
GENERATION is a generation number of the current profile." GENERATION is a generation number of the current profile."
(guix-generation-packages-buffer (guix-ui-current-profile) (guix-generation-packages-buffer (guix-ui-current-profile)
generation)) generation
(guix-system-generation?)))
;;; Interactive commands ;;; Interactive commands
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment