emacs: factor out common overrides for elpa packages

This commit is contained in:
Lin Jian 2024-09-14 12:43:06 +08:00
parent 18c0991315
commit 9928ed446d
No known key found for this signature in database
GPG Key ID: A6698D36434F75A5
3 changed files with 64 additions and 81 deletions

View File

@ -0,0 +1,55 @@
pkgs:
self: super:
let
libExt = pkgs.stdenv.hostPlatform.extensions.sharedLibrary;
in
{
# TODO delete this when we get upstream fix https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73241
eglot = super.eglot.overrideAttrs (old: {
postInstall =
old.postInstall or ""
+ ''
local info_file=eglot.info
pushd $out/share/emacs/site-lisp/elpa/eglot-*
# specify output info file to override the one defined in eglot.texi
makeinfo --output=$info_file eglot.texi
install-info $info_file dir
popd
'';
});
# native compilation for tests/seq-tests.el never ends
# delete tests/seq-tests.el to workaround this
seq = super.seq.overrideAttrs (old: {
dontUnpack = false;
postUnpack =
old.postUnpack or ""
+ "\n"
+ ''
local content_directory=$(echo seq-*)
rm --verbose $content_directory/tests/seq-tests.el
src=$PWD/$content_directory.tar
tar --create --verbose --file=$src $content_directory
'';
});
xeft = super.xeft.overrideAttrs (old: {
dontUnpack = false;
buildInputs = old.buildInputs or [ ] ++ [ pkgs.xapian ];
buildPhase =
old.buildPhase or ""
+ ''
$CXX -shared -o xapian-lite${libExt} xapian-lite.cc $NIX_CFLAGS_COMPILE -lxapian
'';
postInstall =
old.postInstall or ""
+ "\n"
+ ''
outd=$out/share/emacs/site-lisp/elpa/xeft-*
install -m444 -t $outd xapian-lite${libExt}
rm $outd/xapian-lite.cc $outd/emacs-module.h $outd/emacs-module-prelude.h $outd/demo.gif $outd/Makefile
'';
});
}

View File

@ -47,52 +47,16 @@ self: let
super = imported;
overrides = {
eglot = super.eglot.overrideAttrs (old: {
postInstall = (old.postInstall or "") + ''
local info_file=eglot.info
pushd $out/share/emacs/site-lisp/elpa/eglot-*
# specify output info file to override the one defined in eglot.texi
makeinfo --output=$info_file eglot.texi
install-info $info_file dir
popd
'';
});
commonOverrides = import ./elpa-common-overrides.nix pkgs;
overrides = self: super: {
pq = super.pq.overrideAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.postgresql ];
});
xeft = super.xeft.overrideAttrs (old: let
libExt = pkgs.stdenv.hostPlatform.extensions.sharedLibrary;
in {
dontUnpack = false;
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.xapian ];
buildPhase = (old.buildPhase or "") + ''
$CXX -shared -o xapian-lite${libExt} xapian-lite.cc $NIX_CFLAGS_COMPILE -lxapian
'';
postInstall = (old.postInstall or "") + "\n" + ''
outd=$out/share/emacs/site-lisp/elpa/xeft-*
install -m444 -t $outd xapian-lite${libExt}
rm $outd/xapian-lite.cc $outd/emacs-module.h $outd/emacs-module-prelude.h $outd/demo.gif $outd/Makefile
'';
});
# native compilation for tests/seq-tests.el never ends
# delete tests/seq-tests.el to workaround this
seq = super.seq.overrideAttrs (old: {
dontUnpack = false;
postUnpack = (old.postUnpack or "") + "\n" + ''
local content_directory=$(echo seq-*)
rm --verbose $content_directory/tests/seq-tests.el
src=$PWD/$content_directory.tar
tar --create --verbose --file=$src $content_directory
'';
});
};
elpaDevelPackages = super // overrides;
elpaDevelPackages =
let super' = super // (commonOverrides self super); in super' // (overrides self super');
in elpaDevelPackages);

View File

@ -47,7 +47,9 @@ self: let
super = imported;
overrides = {
commonOverrides = import ./elpa-common-overrides.nix pkgs;
overrides = self: super: {
# upstream issue: Wrong type argument: arrayp, nil
org-transclusion =
if super.org-transclusion.version == "1.2.0"
@ -98,17 +100,6 @@ self: let
};
});
eglot = super.eglot.overrideAttrs (old: {
postInstall = (old.postInstall or "") + ''
local info_file=eglot.info
pushd $out/share/emacs/site-lisp/elpa/eglot-*
# specify output info file to override the one defined in eglot.texi
makeinfo --output=$info_file eglot.texi
install-info $info_file dir
popd
'';
});
jinx = super.jinx.overrideAttrs (old: let
libExt = pkgs.stdenv.hostPlatform.extensions.sharedLibrary;
in {
@ -150,38 +141,11 @@ self: let
}
);
xeft = super.xeft.overrideAttrs (old: let
libExt = pkgs.stdenv.hostPlatform.extensions.sharedLibrary;
in {
dontUnpack = false;
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.xapian ];
buildPhase = (old.buildPhase or "") + ''
$CXX -shared -o xapian-lite${libExt} xapian-lite.cc $NIX_CFLAGS_COMPILE -lxapian
'';
postInstall = (old.postInstall or "") + "\n" + ''
outd=$out/share/emacs/site-lisp/elpa/xeft-*
install -m444 -t $outd xapian-lite${libExt}
rm $outd/xapian-lite.cc $outd/emacs-module.h $outd/emacs-module-prelude.h $outd/demo.gif $outd/Makefile
'';
});
# native compilation for tests/seq-tests.el never ends
# delete tests/seq-tests.el to workaround this
seq = super.seq.overrideAttrs (old: {
dontUnpack = false;
postUnpack = (old.postUnpack or "") + "\n" + ''
local content_directory=$(echo seq-*)
rm --verbose $content_directory/tests/seq-tests.el
src=$PWD/$content_directory.tar
tar --create --verbose --file=$src $content_directory
'';
});
};
elpaPackages = super // overrides;
elpaPackages =
let super' = super // (commonOverrides self super); in super' // (overrides self super');
in elpaPackages);