nixpkgs/pkgs/build-support/emacs/melpa.nix
Thomas Tuegel fb7749620b
melpaBuild: Get package-build from melpa/package-build
This commit causes melpaBuild to use package-build from melpa/package-build
instead of melpa/melpa. Development of package-build happens in the former
repository whereas the latter is much larger, containing also the MELPA
recipes. We do not need to fetch the MELPA recipes from melpa/melpa, as we fetch
them one-by-one for Nixpkgs.
2018-11-27 09:36:28 -06:00

97 lines
1.9 KiB
Nix

# builder for Emacs packages built for packages.el
# using MELPA package-build.el
{ lib, stdenv, fetchFromGitHub, emacs, texinfo }:
with lib;
{ /*
pname: Nix package name without special symbols and without version or
"emacs-" prefix.
*/
pname
/*
ename: Original Emacs package name, possibly containing special symbols.
*/
, ename ? null
, version
, recipe
, meta ? {}
, ...
}@args:
let
defaultMeta = {
homepage = args.src.meta.homepage or "http://melpa.org/#/${pname}";
};
in
import ./generic.nix { inherit lib stdenv emacs texinfo; } ({
ename =
if isNull(ename)
then pname
else ename;
packageBuild = fetchFromGitHub {
owner = "melpa";
repo = "package-build";
rev = "0a22c3fbbf661822ec1791739953b937a12fa623";
sha256 = "0dpy5p34il600sc8ic5jdgb3glya9si3lrvhxab0swks8fdydjgs";
};
elpa2nix = ./elpa2nix.el;
melpa2nix = ./melpa2nix.el;
preUnpack = ''
mkdir -p "$NIX_BUILD_TOP/recipes"
if [ -n "$recipe" ]; then
cp "$recipe" "$NIX_BUILD_TOP/recipes/$ename"
fi
ln -s "$packageBuild" "$NIX_BUILD_TOP/package-build"
mkdir -p "$NIX_BUILD_TOP/packages"
'';
postUnpack = ''
mkdir -p "$NIX_BUILD_TOP/working"
ln -s "$NIX_BUILD_TOP/$sourceRoot" "$NIX_BUILD_TOP/working/$ename"
'';
buildPhase = ''
runHook preBuild
cd "$NIX_BUILD_TOP"
emacs --batch -Q \
-L "$NIX_BUILD_TOP/package-build" \
-l "$melpa2nix" \
-f melpa2nix-build-package \
$ename $version
runHook postBuild
'';
installPhase = ''
runHook preInstall
archive="$NIX_BUILD_TOP/packages/$ename-$version.el"
if [ ! -f "$archive" ]; then
archive="$NIX_BUILD_TOP/packages/$ename-$version.tar"
fi
emacs --batch -Q \
-l "$elpa2nix" \
-f elpa2nix-install-package \
"$archive" "$out/share/emacs/site-lisp/elpa"
runHook postInstall
'';
meta = defaultMeta // meta;
}
// removeAttrs args [ "meta" ])