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 01:44:44 +01: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 12:17:43 +01: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 19:31:21 +01:00
|
|
|
, ename ? null
|
2015-02-17 23:06:27 +00:00
|
|
|
, version
|
2018-07-16 02:52:41 +01: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 15:06:12 +01: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 19:31:21 +01:00
|
|
|
ename =
|
|
|
|
if isNull(ename)
|
|
|
|
then pname
|
|
|
|
else ename;
|
|
|
|
|
2018-07-16 02:52:41 +01:00
|
|
|
melpa = fetchFromGitHub {
|
|
|
|
owner = "melpa";
|
|
|
|
repo = "melpa";
|
|
|
|
rev = "7103313a7c31bb1ebb71419e365cd2e279ee4609";
|
|
|
|
sha256 = "0m10f83ix0mzjk0vjd4kkb1m1p4b8ha0ll2yjsgk9bqjd7fwapqb";
|
|
|
|
};
|
2015-02-17 23:06:27 +00:00
|
|
|
|
2018-07-16 02:52:41 +01:00
|
|
|
elpa2nix = ./elpa2nix.el;
|
|
|
|
melpa2nix = ./melpa2nix.el;
|
2016-01-16 16:01:33 +00:00
|
|
|
|
2018-07-16 02:52:41 +01:00
|
|
|
preUnpack = ''
|
|
|
|
mkdir -p "$NIX_BUILD_TOP/recipes"
|
|
|
|
if [ -n "$recipe" ]; then
|
2018-07-23 12:17:43 +01:00
|
|
|
cp "$recipe" "$NIX_BUILD_TOP/recipes/$ename"
|
2018-07-16 02:52:41 +01:00
|
|
|
fi
|
2015-02-17 23:06:27 +00:00
|
|
|
|
2018-07-16 02:52:41 +01:00
|
|
|
ln -s "$melpa/package-build" "$NIX_BUILD_TOP/package-build"
|
2016-01-16 16:01:33 +00:00
|
|
|
|
2018-07-16 02:52:41 +01:00
|
|
|
mkdir -p "$NIX_BUILD_TOP/packages"
|
|
|
|
'';
|
|
|
|
|
|
|
|
postUnpack = ''
|
|
|
|
mkdir -p "$NIX_BUILD_TOP/working"
|
2018-07-23 12:17:43 +01:00
|
|
|
ln -s "$NIX_BUILD_TOP/$sourceRoot" "$NIX_BUILD_TOP/working/$ename"
|
2018-07-16 02:52:41 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase =
|
|
|
|
''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
cd "$NIX_BUILD_TOP"
|
|
|
|
|
|
|
|
emacs --batch -Q \
|
|
|
|
-L "$melpa/package-build" \
|
|
|
|
-l "$melpa2nix" \
|
|
|
|
-f melpa2nix-build-package \
|
2018-07-23 12:17:43 +01:00
|
|
|
$ename $version
|
2018-07-16 02:52:41 +01:00
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
2015-02-17 23:06:27 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
2018-07-23 12:17:43 +01:00
|
|
|
archive="$NIX_BUILD_TOP/packages/$ename-$version.el"
|
2018-07-16 02:52:41 +01:00
|
|
|
if [ ! -f "$archive" ]; then
|
2018-07-23 12:17:43 +01:00
|
|
|
archive="$NIX_BUILD_TOP/packages/$ename-$version.tar"
|
2018-07-16 02:52:41 +01: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 02:52:41 +01:00
|
|
|
// removeAttrs args [ "meta" ])
|