From: Mekeor Melire <mekeor@posteo.de>
To: Mitchell Schmeisser <mitchellschmeisser@librem.one>
Cc: guix-devel@gnu.org
Subject: Re: Proof of Concept: Import Emacs' use-packaged packages into Guix' manifest.scm
Date: Thu, 02 Feb 2023 09:44:49 +0000 [thread overview]
Message-ID: <87wn50xu5i.fsf@posteo.de> (raw)
In-Reply-To: <87h6xgwdt8.fsf@librem.one>
2022-12-27 19:51 mitchellschmeisser@librem.one:
> Mekeor Melire <mekeor@posteo.de> writes:
>
> Here is a naive implementation which extends use-package to use
> guix to ensure packages.
Thank you very much for this great snippet of code. I just
successfully set it up locally and I'm very happy.
Would you like to create a public Git repository for this
elisp-package so that we can collaborate on it? If you don't have
time to do it, I can create a public Git repository (with your
copyright note; under GPLv3+?; formally owned by an
"organization").
Personally, I'm also very much of a noob in things elisp. But
intuitively, I'd suggest these changes:
> It is a bit annoying at first because it prompts for y/n
> verification for every package but I think this behavior is
> desirable.
Personally, I found that behaviour a little tidyous. I'd suggest
to make it at least configurable.
> #+BEGIN_SRC emacs-lisp
> (require 'guix)
> (require 'guix-profiles)
> (require 'guix-read)
> (require 'guix-ui-package)
>
>
> (defgroup use-package-guix nil
What do you think about naming this package/feature
"use-package-ensure-guix" and using that as a prefix for all other
functions and variables -- except for use-package-ensure-guix? I
think "use-package-ensure-guix" would be a good package name
because it's pretty much the only (important) function which this
packages aims to offer. So, …
> "use-package support for guix" :group 'use-package-ensure)
>
> (defcustom use-package-profile (concat (getenv "HOME")
> "/.emacs.d/guix-profile")
… this variable would then perhaps be renamed into
"use-package-ensure-guix-profile" or so.
> "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))
(This function could be removed, I think.)
> (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)
What is the purpose of this long (progn …)? Could we instead
simply write (guix-install-package package)?
>
> (error (display-warning 'use-package (format
> "Failed to
> install %s: %s" name (error-message-string err))
> :error)))))))))
I'd suggest to miss the "error" label on this message, and rather
label it as "warning" (which is the default). We could also
suggest to add ":ensure nil" if it's a built-in feature. (E.g. in
case of (use-package recentf).)
> ;;;###autoload
> (add-to-list 'load-path (concat use-package-profile
> "/share/emacs/site-lisp"))
>
> (provide 'use-package-guix)
> #+END_SRC
Finally, I'm not sure if installing packages from my custom local
guix-channel succeeded. I need to retry and investigate more.
next prev parent reply other threads:[~2023-02-02 10:02 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.
2023-02-02 9:44 ` Mekeor Melire [this message]
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=87wn50xu5i.fsf@posteo.de \
--to=mekeor@posteo.de \
--cc=guix-devel@gnu.org \
--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.