emacsPackages.mu4e: init at 1.10.7

This patch packages mu4e as an Emacs lisp package based on the mu4e
output of the multiple-output package mu, which makes mu4e a good
citizen of Emacs lisp packages in two aspects.

First, mu4e now utilizes the Emacs lisp package infrastructure in
Nixpkgs.  This allows users who want to do AOT native compilation for
non-default Emacs variants[0] to build only mu4e itself instead of the
whole mu package[1].

Second, mu4e now conforms to the Emacs builtin package manager[2].
Without this patch, mu4e autoloaded commands do not work
out-of-the-box[3] because its directory is added to load-path by
site-start.el after the initialization of package-directory-list,
which causes package-activate-all to not load mu4e-autoloads.el.  This
patch fixes this issue when mu4e is installed to Emacs using the
withPackages wrapper[4].

[0]: such as emacs-pgtk
[1]: mu.override { emacs = emacs-pgtk; }
[2]: package.el
[3]: either (require 'mu4e) or (require 'mu4e-autoloads) is needed to
be called before an autoloaded command is called
[4]: emacs-pgtk.pkgs.withPackages (epkgs: [ epkgs.mu4e ])
This commit is contained in:
Lin Jian 2023-09-04 01:16:20 +08:00 committed by Anderson Torres
parent 2081e7e07d
commit ac4f5079f7
4 changed files with 48 additions and 11 deletions

View File

@ -79,6 +79,8 @@
- `pass` now does not contain `password-store.el`. Users should get `password-store.el` from Emacs lisp package set `emacs.pkgs.password-store`.
- `mu` now does not install `mu4e` files by default. Users should get `mu4e` from Emacs lisp package set `emacs.pkgs.mu4e`.
- `mariadb` now defaults to `mariadb_1011` instead of `mariadb_106`, meaning the default version was upgraded from 10.6.x to 10.11.x. See the [upgrade notes](https://mariadb.com/kb/en/upgrading-from-mariadb-10-6-to-mariadb-10-11/) for potential issues.
- `getent` has been moved from `glibc`'s `bin` output to its own dedicated output, reducing closure size for many dependents. Dependents using the `getent` alias should not be affected; others should move from using `glibc.bin` or `getBin glibc` to `getent` (which also improves compatibility with non-glibc platforms).

View File

@ -61,6 +61,8 @@ in
_map = self.map;
};
mu4e = callPackage ./manual-packages/mu4e { };
ott-mode = callPackage ./manual-packages/ott-mode { };
perl-completion = callPackage ./manual-packages/perl-completion { };

View File

@ -0,0 +1,33 @@
{ elpaBuild, mu }:
let
pname = "mu4e";
version = mu.mu4e.version;
in
elpaBuild {
inherit pname version;
src = mu.mu4e;
propagatedUserEnvPkgs = [ mu ];
dontUnpack = false;
# prepare a multi-file package tar archive according to info
# "(elisp) Multi-file Packages" for elpaBuild to install
postUnpack = ''
pushd mu-*-mu4e
local content_directory=${pname}-${version}
mkdir $content_directory
cp --verbose share/emacs/site-lisp/mu4e/*.el $content_directory/
rm --verbose --force $content_directory/mu4e-autoloads.el
cp --verbose share/info/* $content_directory/
src=$PWD/$content_directory.tar
tar --create --verbose --file=$src $content_directory
popd
'';
meta = mu.meta // {
description = "A full-featured e-mail client";
};
}

View File

@ -10,6 +10,7 @@
, gmime3
, texinfo
, xapian
, fetchpatch
}:
stdenv.mkDerivation rec {
@ -25,6 +26,14 @@ stdenv.mkDerivation rec {
hash = "sha256-x1TsyTOK5U6/Y3QInm+XQ7T32X49iwa+4UnaHdiyqCI=";
};
patches = [
(fetchpatch {
name = "add-mu4e-pkg.el";
url = "https://github.com/djcb/mu/commit/00f7053d51105eea0c72151f1a8cf0b6d8478e4e.patch";
hash = "sha256-21c7djmYTcqyyygqByo9vu/GsH8WMYcq8NOAvJsS5AQ=";
})
];
postPatch = ''
# Fix mu4e-builddir (set it to $out)
substituteInPlace mu4e/mu4e-config.el.in \
@ -33,17 +42,8 @@ stdenv.mkDerivation rec {
--replace "/bin/rm" "${coreutils}/bin/rm"
'';
# AOT native-comp, mostly copied from pkgs/build-support/emacs/generic.nix
postInstall = lib.optionalString (emacs.withNativeCompilation or false) ''
mkdir -p $mu4e/share/emacs/native-lisp
export EMACSLOADPATH=$mu4e/share/emacs/site-lisp/mu4e:
export EMACSNATIVELOADPATH=$mu4e/share/emacs/native-lisp:
find $mu4e/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\" \"$mu4e/share/emacs/site-lisp/mu4e\")"
postInstall = ''
rm --verbose $mu4e/share/emacs/site-lisp/mu4e/*.elc
'';
# move only the mu4e info manual