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