nixpkgs/pkgs/tools/networking/mu/default.nix
Lin Jian e7820571fc mu: generate mu4e-autoloads.el
* What is autoload?

Basically, it allows you to delay the loading of a package[1].

* What is a name-autoloads.el file?

When installing a package using package.el, Emacs generates[1] a
name-autoloads.el file for that package, which is used to autoload the
principal user commands defined[2][3] in the package.

* What problem does this patch solve?

There are some autoload commands defined[3] by mu4e.  Before, those
autoload commands cannot be autoloaded because of the missing
mu4e-autoloads.el file since mu4e installed from nixpkgs does not use
package.el.  This patch fixes that.

To sum up, with this patch, you can call (mu4e) without
calling (require 'mu4e) first.

* Isn't it better to contribute to the build system of the upstream mu
project to generate that mu4e-autoloads.el file?

It seems impossible[4] to do so.

[1]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Autoload.html
[2]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Packaging-Basics.html
[3]: 581f8d7e92/mu4e/mu4e.el (L58)
[4]: https://github.com/djcb/mu/pull/2313
2023-05-18 08:04:40 -03:00

67 lines
1.8 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, meson
, ninja
, pkg-config
, coreutils
, emacs
, glib
, gmime3
, texinfo
, xapian
}:
stdenv.mkDerivation rec {
pname = "mu";
version = "1.10.3";
src = fetchFromGitHub {
owner = "djcb";
repo = "mu";
rev = "v${version}";
hash = "sha256-AqIPdKdNKLnAHIlqgs8zzm7j+iwNvDFWslvp8RjQPnI=";
};
postPatch = ''
# Fix mu4e-builddir (set it to $out)
substituteInPlace mu4e/mu4e-config.el.in \
--replace "@abs_top_builddir@" "$out"
substituteInPlace lib/utils/mu-test-utils.cc \
--replace "/bin/rm" "${coreutils}/bin/rm"
'';
# AOT native-comp, mostly copied from pkgs/build-support/emacs/generic.nix
postInstall = lib.optionalString (emacs.nativeComp or false) ''
mkdir -p $out/share/emacs/native-lisp
export EMACSLOADPATH=$out/share/emacs/site-lisp/mu4e:
export EMACSNATIVELOADPATH=$out/share/emacs/native-lisp:
find $out/share/emacs -type f -name '*.el' -print0 \
| xargs -0 -I {} -n 1 -P $NIX_BUILD_CORES sh -c \
"emacs --batch --eval '(setq large-file-warning-threshold nil)' -f batch-native-compile {} || true"
'' + ''
emacs --batch -l package --eval "(package-generate-autoloads \"mu4e\" \"$out/share/emacs/site-lisp/mu4e\")"
'';
buildInputs = [ emacs glib gmime3 texinfo xapian ];
mesonFlags = [
"-Dguile=disabled"
"-Dreadline=disabled"
];
nativeBuildInputs = [ pkg-config meson ninja ];
doCheck = true;
meta = with lib; {
description = "A collection of utilities for indexing and searching Maildirs";
license = licenses.gpl3Plus;
homepage = "https://www.djcbsoftware.nl/code/mu/";
changelog = "https://github.com/djcb/mu/releases/tag/v${version}";
maintainers = with maintainers; [ antono chvp peterhoeg ];
platforms = platforms.unix;
};
}