emacs-twist / twist.nix

Build an entire Emacs configuration as a Nix package in a pure, reproducible way
GNU General Public License v3.0
66 stars 6 forks source link

How to install package dependent on external artifact like `mu4e` #152

Open brsvh opened 5 months ago

brsvh commented 5 months ago

Recently, I am trying to incorporate mu4e into my configuration, but I don't know how build it by Twist.

The building of mu4e is dependent on the artifacts of mu.

For example, as build by nixpkgs elispPackages.

https://github.com/NixOS/nixpkgs/blob/b9c6b11eafbb693c3d9d820bea1636a51c87b2a5/pkgs/applications/editors/emacs/elisp-packages/manual-packages/mu4e/default.nix#L7-L33

I attempted to independently build its Emacs Lisp portion, but it appears that there are many missing components that I am unsure how to address. For example, mu-guile and a mu4e-config.el generated from the template.

https://github.com/djcb/mu/blob/62f0a9a902031d172e03e8caaaad013a1798749f/mu4e/meson.build#L19-L27

I am interested in understanding the methods available for extracting the mu output and integrating it with twist. Alternatively, are there other reproducible build strategies?

akirak commented 5 months ago

I am interested in understanding the methods available for extracting the mu output and integrating it with twist

emacsTwist accepts inputOverrides which can be used to moderate the input of a package. It is originally meant to temporarily work around upstream issues, but it can be used to permanently override the source (example).

In this case, you could use this:

emacsTwist {
  ...
  inputOverrides = {
    mu4e = _: _: {
      src = nixpkgs.mu.mu4e;
    };
  };
}

It seems that mu4e is not registered to any of GNU/NonGNU ELPA and MELPA, so you'll have to define a recipe for yourself (which I assume you have been already doing).

akirak commented 5 months ago

You can browse the content of nixpkgs.mu.mu4e by pasting the output of the following command into Emacs dired/find-file:

nix build nixpkgs#mu.mu4e --print-out-paths

and the MELPA recipe should be

(mu4e :fetcher github :repo "djcb/mu"
  :files "share/emacs/site-lisp/mu4e/*.el")

Only :files field matters here, as the repository location will be overridden by inputOverrides above.

If you encounter a further problem with building mu4e, please report it in this ticket.

brsvh commented 5 months ago

I appreciate your help, this way works fine within my configuration.

However, the MELPA Recipe appears somewhat peculiar, as we do not require a definitive upstream repository after overriding.

Furthermore, should we consider adding a local store or nixpkgs as an optional pseudo fetcher backend for the elisp-helpers MELPA parser? e.g., support a recipe like:

(mu4e :fetcher nixpkgs :package "mu.mu4e" :files ("**/*.el"))

It is merely a casual remark, it is anticipated that there will be limited applications for it.

akirak commented 5 months ago

Mu4e is quite an exceptional case. It is known to many Emacs users but unavailable from any of the popular registries.

I am unwilling to add extra fetchers that are not supported by MELPA. A better way to support mu4e (and possibly some other manual packages in nixpkgs) would be to allow the user to define a custom registry in Nix (like where each package just takes files from a Nix path), so the user won't have to define recipes for his/her custom packages. Maybe I will add the functionality in the future.