2020-04-24 23:36:52 +00:00
|
|
|
# generic builder for Emacs packages
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv, emacs, texinfo, ... }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{ pname
|
|
|
|
, version ? null
|
|
|
|
|
|
|
|
, buildInputs ? []
|
|
|
|
, packageRequires ? []
|
|
|
|
|
|
|
|
, meta ? {}
|
|
|
|
|
|
|
|
, ...
|
|
|
|
}@args:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
defaultMeta = {
|
|
|
|
broken = false;
|
|
|
|
platforms = emacs.meta.platforms;
|
|
|
|
} // optionalAttrs ((args.src.meta.homepage or "") != "") {
|
|
|
|
homepage = args.src.meta.homepage;
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation ({
|
|
|
|
name = "emacs-${pname}${optionalString (version != null) "-${version}"}";
|
|
|
|
|
|
|
|
unpackCmd = ''
|
|
|
|
case "$curSrc" in
|
|
|
|
*.el)
|
|
|
|
# keep original source filename without the hash
|
|
|
|
local filename=$(basename "$curSrc")
|
|
|
|
filename="''${filename:33}"
|
|
|
|
cp $curSrc $filename
|
|
|
|
chmod +w $filename
|
|
|
|
sourceRoot="."
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
_defaultUnpack "$curSrc"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildInputs = [emacs texinfo] ++ packageRequires ++ buildInputs;
|
|
|
|
propagatedBuildInputs = packageRequires;
|
|
|
|
propagatedUserEnvPkgs = packageRequires;
|
|
|
|
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
meta = defaultMeta // meta;
|
|
|
|
}
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
// lib.optionalAttrs (emacs.nativeComp or false) {
|
|
|
|
|
|
|
|
LIBRARY_PATH = "${lib.getLib stdenv.cc.libc}/lib";
|
|
|
|
|
2020-12-25 13:55:36 +00:00
|
|
|
addEmacsNativeLoadPath = true;
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
postInstall = ''
|
2020-12-25 13:55:36 +00:00
|
|
|
find $out/share/emacs -type f -name '*.el' -print0 \
|
|
|
|
| xargs -0 -n 1 -I {} -P $NIX_BUILD_CORES sh -c \
|
|
|
|
"emacs --batch --eval=\"(add-to-list 'comp-eln-load-path \\\"$out/share/emacs/native-lisp/\\\")\" -f batch-native-compile {} || true"
|
2020-08-20 17:08:02 +00:00
|
|
|
'';
|
|
|
|
}
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
// removeAttrs args [ "buildInputs" "packageRequires"
|
|
|
|
"meta"
|
|
|
|
])
|