You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
2.3 KiB
96 lines
2.3 KiB
11 years ago
|
# generic builder for Emacs packages
|
||
|
|
||
3 years ago
|
{ lib, stdenv, emacs, texinfo, writeText, gcc, ... }:
|
||
11 years ago
|
|
||
|
with lib;
|
||
|
|
||
|
{ pname
|
||
|
, version ? null
|
||
|
|
||
|
, buildInputs ? []
|
||
|
, packageRequires ? []
|
||
|
|
||
|
, meta ? {}
|
||
|
|
||
|
, ...
|
||
|
}@args:
|
||
|
|
||
|
let
|
||
9 years ago
|
|
||
11 years ago
|
defaultMeta = {
|
||
|
broken = false;
|
||
|
platforms = emacs.meta.platforms;
|
||
9 years ago
|
} // optionalAttrs ((args.src.meta.homepage or "") != "") {
|
||
|
homepage = args.src.meta.homepage;
|
||
11 years ago
|
};
|
||
9 years ago
|
|
||
11 years ago
|
in
|
||
|
|
||
|
stdenv.mkDerivation ({
|
||
|
name = "emacs-${pname}${optionalString (version != null) "-${version}"}";
|
||
|
|
||
9 years ago
|
unpackCmd = ''
|
||
|
case "$curSrc" in
|
||
|
*.el)
|
||
9 years ago
|
# keep original source filename without the hash
|
||
|
local filename=$(basename "$curSrc")
|
||
|
filename="''${filename:33}"
|
||
|
cp $curSrc $filename
|
||
|
chmod +w $filename
|
||
9 years ago
|
sourceRoot="."
|
||
|
;;
|
||
|
*)
|
||
|
_defaultUnpack "$curSrc"
|
||
|
;;
|
||
|
esac
|
||
|
'';
|
||
|
|
||
11 years ago
|
buildInputs = [emacs texinfo] ++ packageRequires ++ buildInputs;
|
||
|
propagatedBuildInputs = packageRequires;
|
||
|
propagatedUserEnvPkgs = packageRequires;
|
||
|
|
||
3 years ago
|
setupHook = writeText "setup-hook.sh" ''
|
||
|
source ${./emacs-funcs.sh}
|
||
|
|
||
|
if [[ ! -v emacsHookDone ]]; then
|
||
|
emacsHookDone=1
|
||
|
|
||
|
# If this is for a wrapper derivation, emacs and the dependencies are all
|
||
|
# run-time dependencies. If this is for precompiling packages into bytecode,
|
||
|
# emacs is a compile-time dependency of the package.
|
||
|
addEnvHooks "$hostOffset" addEmacsVars
|
||
|
addEnvHooks "$targetOffset" addEmacsVars
|
||
|
fi
|
||
|
'';
|
||
11 years ago
|
|
||
|
doCheck = false;
|
||
|
|
||
|
meta = defaultMeta // meta;
|
||
|
}
|
||
|
|
||
4 years ago
|
// lib.optionalAttrs (emacs.nativeComp or false) {
|
||
|
|
||
|
LIBRARY_PATH = "${lib.getLib stdenv.cc.libc}/lib";
|
||
|
|
||
3 years ago
|
nativeBuildInputs = [ gcc ];
|
||
|
|
||
4 years ago
|
addEmacsNativeLoadPath = true;
|
||
|
|
||
4 years ago
|
postInstall = ''
|
||
3 years ago
|
# Besides adding the output directory to the native load path, make sure
|
||
|
# the current package's elisp files are in the load path, otherwise
|
||
|
# (require 'file-b) from file-a.el in the same package will fail.
|
||
|
mkdir -p $out/share/emacs/native-lisp
|
||
|
source ${./emacs-funcs.sh}
|
||
|
addEmacsVars "$out"
|
||
|
|
||
4 years ago
|
find $out/share/emacs -type f -name '*.el' -print0 \
|
||
|
| xargs -0 -n 1 -I {} -P $NIX_BUILD_CORES sh -c \
|
||
3 years ago
|
"emacs --batch -f batch-native-compile {} || true"
|
||
4 years ago
|
'';
|
||
|
}
|
||
|
|
||
11 years ago
|
// removeAttrs args [ "buildInputs" "packageRequires"
|
||
|
"meta"
|
||
|
])
|