2014-01-20 23:57:04 +00:00
|
|
|
# builder for Emacs packages built for packages.el
|
|
|
|
# using MELPA package-build.el
|
2015-02-17 23:06:27 +00:00
|
|
|
|
2018-07-21 00:44:44 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, emacs, texinfo }:
|
2014-01-20 23:57:04 +00:00
|
|
|
|
|
|
|
with lib;
|
2015-02-17 23:06:27 +00:00
|
|
|
|
2018-07-23 11:17:43 +00:00
|
|
|
{ /*
|
|
|
|
pname: Nix package name without special symbols and without version or
|
|
|
|
"emacs-" prefix.
|
|
|
|
*/
|
|
|
|
pname
|
|
|
|
/*
|
|
|
|
ename: Original Emacs package name, possibly containing special symbols.
|
|
|
|
*/
|
2018-07-24 18:31:21 +00:00
|
|
|
, ename ? null
|
2015-02-17 23:06:27 +00:00
|
|
|
, version
|
2018-07-16 01:52:41 +00:00
|
|
|
, recipe
|
2015-02-17 23:06:27 +00:00
|
|
|
, meta ? {}
|
2014-01-20 23:57:04 +00:00
|
|
|
, ...
|
|
|
|
}@args:
|
2015-02-17 23:06:27 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
defaultMeta = {
|
2015-05-24 14:06:12 +00:00
|
|
|
homepage = args.src.meta.homepage or "http://melpa.org/#/${pname}";
|
2015-02-17 23:06:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
2014-01-20 23:57:04 +00:00
|
|
|
import ./generic.nix { inherit lib stdenv emacs texinfo; } ({
|
2015-02-17 23:06:27 +00:00
|
|
|
|
2018-07-24 18:31:21 +00:00
|
|
|
ename =
|
|
|
|
if isNull(ename)
|
|
|
|
then pname
|
|
|
|
else ename;
|
|
|
|
|
2018-11-25 21:19:50 +00:00
|
|
|
packageBuild = fetchFromGitHub {
|
2018-07-16 01:52:41 +00:00
|
|
|
owner = "melpa";
|
2018-11-25 21:19:50 +00:00
|
|
|
repo = "package-build";
|
|
|
|
rev = "0a22c3fbbf661822ec1791739953b937a12fa623";
|
|
|
|
sha256 = "0dpy5p34il600sc8ic5jdgb3glya9si3lrvhxab0swks8fdydjgs";
|
2018-07-16 01:52:41 +00:00
|
|
|
};
|
2015-02-17 23:06:27 +00:00
|
|
|
|
2018-07-16 01:52:41 +00:00
|
|
|
elpa2nix = ./elpa2nix.el;
|
|
|
|
melpa2nix = ./melpa2nix.el;
|
2016-01-16 16:01:33 +00:00
|
|
|
|
2018-07-16 01:52:41 +00:00
|
|
|
preUnpack = ''
|
|
|
|
mkdir -p "$NIX_BUILD_TOP/recipes"
|
|
|
|
if [ -n "$recipe" ]; then
|
2018-07-23 11:17:43 +00:00
|
|
|
cp "$recipe" "$NIX_BUILD_TOP/recipes/$ename"
|
2018-07-16 01:52:41 +00:00
|
|
|
fi
|
2015-02-17 23:06:27 +00:00
|
|
|
|
2018-11-25 21:19:50 +00:00
|
|
|
ln -s "$packageBuild" "$NIX_BUILD_TOP/package-build"
|
2016-01-16 16:01:33 +00:00
|
|
|
|
2018-07-16 01:52:41 +00:00
|
|
|
mkdir -p "$NIX_BUILD_TOP/packages"
|
|
|
|
'';
|
|
|
|
|
|
|
|
postUnpack = ''
|
|
|
|
mkdir -p "$NIX_BUILD_TOP/working"
|
2018-07-23 11:17:43 +00:00
|
|
|
ln -s "$NIX_BUILD_TOP/$sourceRoot" "$NIX_BUILD_TOP/working/$ename"
|
2018-07-16 01:52:41 +00:00
|
|
|
'';
|
|
|
|
|
2018-11-27 05:23:04 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2018-07-16 01:52:41 +00:00
|
|
|
|
2018-11-27 05:23:04 +00:00
|
|
|
cd "$NIX_BUILD_TOP"
|
2018-07-16 01:52:41 +00:00
|
|
|
|
2018-11-27 05:23:04 +00:00
|
|
|
emacs --batch -Q \
|
2018-11-25 21:19:50 +00:00
|
|
|
-L "$NIX_BUILD_TOP/package-build" \
|
2018-11-27 05:23:04 +00:00
|
|
|
-l "$melpa2nix" \
|
|
|
|
-f melpa2nix-build-package \
|
|
|
|
$ename $version
|
2018-07-16 01:52:41 +00:00
|
|
|
|
2018-11-27 05:23:04 +00:00
|
|
|
runHook postBuild
|
2018-07-16 01:52:41 +00:00
|
|
|
'';
|
2015-02-17 23:06:27 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
2018-07-23 11:17:43 +00:00
|
|
|
archive="$NIX_BUILD_TOP/packages/$ename-$version.el"
|
2018-07-16 01:52:41 +00:00
|
|
|
if [ ! -f "$archive" ]; then
|
2018-07-23 11:17:43 +00:00
|
|
|
archive="$NIX_BUILD_TOP/packages/$ename-$version.tar"
|
2018-07-16 01:52:41 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
emacs --batch -Q \
|
|
|
|
-l "$elpa2nix" \
|
2016-01-16 23:20:06 +00:00
|
|
|
-f elpa2nix-install-package \
|
2016-01-16 16:01:33 +00:00
|
|
|
"$archive" "$out/share/emacs/site-lisp/elpa"
|
2015-02-17 23:06:27 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = defaultMeta // meta;
|
|
|
|
}
|
|
|
|
|
2018-07-16 01:52:41 +00:00
|
|
|
// removeAttrs args [ "meta" ])
|