From: Mitchell Schmeisser via "Development of GNU Guix and the GNU System distribution." <guix-devel@gnu.org>
To: Mekeor Melire <mekeor@posteo.de>, guix-devel@gnu.org
Subject: Re: Proof of Concept: Import Emacs' use-packaged packages into Guix' manifest.scm
Date: Tue, 27 Dec 2022 19:51:31 -0500 [thread overview]
Message-ID: <87h6xgwdt8.fsf@librem.one> (raw)
In-Reply-To: <87r0wxbhm5.fsf@posteo.de> (Mekeor Melire's message of "Sun, 18 Dec 2022 01:54:06 +0000")
Mekeor Melire <mekeor@posteo.de> writes:
>> Perhaps you are thinking about this upside down?
>>
>> emacs has support for guix via `emacs-guix`.
>> Would it not make more sense to make a drop in replacement for
>> `use-package` which is syntactically identical but instead of
>> downloading stuff from the emacs package eco-system it installs it from
>> guix into a special emacs managed profile.
>>
>> Then to use it you would just install the `guix-emacs-use-package`
>> instead of `emacs-use-package`.
>>
>> - Mitchell
>
> That's an interesting idea, thanks for sharing. I think it'd be nice if you shared it not only with me but with the whole mailing-list (guix-devel).
Here is a naive implementation which extends use-package to use guix to
ensure packages.
It turns out `use-package` allows you to customize the ensure function.
This is mostly a plagiarized version of the use-package-ensure-elpa.
It creates a profile in ~/.emacs.d./guix-profile by default and every
package which is marked `:ensure t` will be prompted for install.
Set `use-package-ensure-function` to #'use-package-ensure-guix.
#+BEGIN_SRC emacs-lisp
(require 'use-package)
(require 'use-package-guix)
(setq use-package-ensure-function #'use-package-ensure-guix)
#+END_SRC
This is kind of nice because we can now use the `emacs-guix` interfaces
for managing our `use-package` specifications i.e. updates/removal
It is a bit annoying at first because it prompts for y/n verification
for every package but I think this behavior is desirable.
This is my first emacs package so I'm sure there are many things which
can be improved.
#+BEGIN_SRC emacs-lisp
(require 'guix)
(require 'guix-profiles)
(require 'guix-read)
(require 'guix-ui-package)
(defgroup use-package-guix nil
"use-package support for guix"
:group 'use-package-ensure)
(defcustom use-package-profile (concat (getenv "HOME") "/.emacs.d/guix-profile")
"Location of use-package guix profile"
:type 'string
:group 'use-package-guix)
(defun guix-package-installed-p (package)
(bui-assoc-value package 'installed))
(defun canonicalize-name (package-name)
"Make sure package name has \"emacs-\" prefix"
(if (string-match "^emacs-.+" package-name)
package-name
(concat "emacs-" package-name)))
(defun emacs-package->guix-package (package)
"Return guix package from package name"
(car (guix-output-list-get-entries use-package-profile 'name
(canonicalize-name package))))
(defun guix-package-id (package)
(bui-entry-non-void-value package 'id))
(defun guix-install-package (package)
(if (guix-package-installed-p package)
t
(guix-process-package-actions
use-package-profile
`((install (,(string-to-number (car (split-string (bui-entry-id package) ":"))) "out"))))
(current-buffer)))
(defun guix-installed-packages ()
(guix-output-list-get-entries use-package-profile 'installed))
(defun use-package-ensure-guix (name args _state &optional _no-refresh)
(dolist (ensure args)
(let ((package
(or (and (eq ensure t)
(use-package-as-symbol name))
ensure)))
(when package
(when (consp package)
(use-package-pin-package (car package) (cdr package))
(setq package (car package)))
(let ((package (emacs-package->guix-package (use-package-as-string package))))
(unless (guix-package-installed-p package)
(condition-case-unless-debug err
(progn
(when (assoc package (bound-and-true-p
package-pinned-packages))
(package-read-all-archive-contents))
(if (assoc package package-archive-contents)
(package-install package)
(package-refresh-contents)
(when (assoc package (bound-and-true-p
package-pinned-packages))
(package-read-all-archive-contents))
(guix-install-package package))
t)
(error
(display-warning 'use-package
(format "Failed to install %s: %s"
name (error-message-string err))
:error)))))))))
;;;###autoload
(add-to-list 'load-path (concat use-package-profile "/share/emacs/site-lisp"))
(provide 'use-package-guix)
#+END_SRC
next prev parent reply other threads:[~2022-12-28 0:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-18 1:54 Proof of Concept: Import Emacs' use-packaged packages into Guix' manifest.scm Mekeor Melire
2022-12-18 8:11 ` Liliana Marie Prikler
2022-12-19 10:15 ` Andrew Tropin
2022-12-20 9:45 ` Mekeor Melire
2022-12-20 14:56 ` Andrew Tropin
2022-12-20 9:16 ` Mekeor Melire
2022-12-20 15:06 ` Andrew Tropin
2022-12-19 10:42 ` zimoun
2022-12-28 0:51 ` Mitchell Schmeisser via Development of GNU Guix and the GNU System distribution. [this message]
2023-02-02 9:44 ` Mekeor Melire
2023-02-03 2:20 ` Mitchell Schmeisser via Development of GNU Guix and the GNU System distribution.
2023-02-03 2:31 ` Mitchell Schmeisser via Development of GNU Guix and the GNU System distribution.
[not found] <875ydxi4xn.fsf@posteo.de>
2022-12-27 18:52 ` Mitchell Schmeisser via Development of GNU Guix and the GNU System distribution.
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=87h6xgwdt8.fsf@librem.one \
--to=guix-devel@gnu.org \
--cc=mekeor@posteo.de \
--cc=mitchellschmeisser@librem.one \
/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.