2014-01-20 23:57:04 +00:00
|
|
|
# generic builder for Emacs packages
|
|
|
|
|
2021-01-26 14:57:21 +00:00
|
|
|
{ lib, stdenv, emacs, texinfo, ... }:
|
2014-01-20 23:57:04 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{ pname
|
|
|
|
, version ? null
|
|
|
|
|
|
|
|
, buildInputs ? []
|
|
|
|
, packageRequires ? []
|
|
|
|
|
|
|
|
, meta ? {}
|
|
|
|
|
|
|
|
, ...
|
|
|
|
}@args:
|
|
|
|
|
|
|
|
let
|
2015-05-24 15:06:12 +01:00
|
|
|
|
2014-01-20 23:57:04 +00:00
|
|
|
defaultMeta = {
|
|
|
|
broken = false;
|
|
|
|
platforms = emacs.meta.platforms;
|
2015-05-24 15:06:12 +01:00
|
|
|
} // optionalAttrs ((args.src.meta.homepage or "") != "") {
|
|
|
|
homepage = args.src.meta.homepage;
|
2014-01-20 23:57:04 +00:00
|
|
|
};
|
2015-05-24 15:06:12 +01:00
|
|
|
|
2014-01-20 23:57:04 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation ({
|
|
|
|
name = "emacs-${pname}${optionalString (version != null) "-${version}"}";
|
|
|
|
|
2015-04-16 16:09:28 +01:00
|
|
|
unpackCmd = ''
|
|
|
|
case "$curSrc" in
|
|
|
|
*.el)
|
2016-01-16 22:47:22 +00:00
|
|
|
# keep original source filename without the hash
|
|
|
|
local filename=$(basename "$curSrc")
|
|
|
|
filename="''${filename:33}"
|
|
|
|
cp $curSrc $filename
|
|
|
|
chmod +w $filename
|
2015-04-16 16:09:28 +01:00
|
|
|
sourceRoot="."
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
_defaultUnpack "$curSrc"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'';
|
|
|
|
|
2014-01-20 23:57:04 +00:00
|
|
|
buildInputs = [emacs texinfo] ++ packageRequires ++ buildInputs;
|
|
|
|
propagatedBuildInputs = packageRequires;
|
|
|
|
propagatedUserEnvPkgs = packageRequires;
|
|
|
|
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
meta = defaultMeta // meta;
|
|
|
|
}
|
|
|
|
|
2020-07-23 20:34:55 +01:00
|
|
|
// lib.optionalAttrs (emacs.nativeComp or false) {
|
|
|
|
|
|
|
|
LIBRARY_PATH = "${lib.getLib stdenv.cc.libc}/lib";
|
|
|
|
|
2020-11-16 19:24:29 +00:00
|
|
|
addEmacsNativeLoadPath = true;
|
|
|
|
|
2020-07-23 20:34:55 +01:00
|
|
|
postInstall = ''
|
2020-11-16 19:24:29 +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-07-23 20:34:55 +01:00
|
|
|
'';
|
|
|
|
}
|
|
|
|
|
2014-01-20 23:57:04 +00:00
|
|
|
// removeAttrs args [ "buildInputs" "packageRequires"
|
|
|
|
"meta"
|
|
|
|
])
|