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
|
|
|
|
2020-12-28 05:12:44 +01:00
|
|
|
{ lib, stdenv, fetchFromGitHub, emacs, texinfo, writeText }:
|
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 = {
|
2020-12-10 22:36:07 +01:00
|
|
|
homepage = args.src.meta.homepage or "https://melpa.org/#/${pname}";
|
2015-02-18 00:06:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
2020-12-28 05:12:44 +01:00
|
|
|
import ./generic.nix { inherit lib stdenv emacs texinfo writeText; } ({
|
2015-02-18 00:06:27 +01:00
|
|
|
|
2018-07-24 20:31:21 +02:00
|
|
|
ename =
|
2019-04-24 05:48:22 +02:00
|
|
|
if ename == null
|
2018-07-24 20:31:21 +02:00
|
|
|
then pname
|
|
|
|
else ename;
|
|
|
|
|
2018-11-25 22:19:50 +01:00
|
|
|
packageBuild = fetchFromGitHub {
|
2018-07-16 03:52:41 +02:00
|
|
|
owner = "melpa";
|
2018-11-25 22:19:50 +01:00
|
|
|
repo = "package-build";
|
|
|
|
rev = "0a22c3fbbf661822ec1791739953b937a12fa623";
|
|
|
|
sha256 = "0dpy5p34il600sc8ic5jdgb3glya9si3lrvhxab0swks8fdydjgs";
|
2018-07-16 03:52:41 +02:00
|
|
|
};
|
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-11-25 22:19:50 +01:00
|
|
|
ln -s "$packageBuild" "$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
|
|
|
'';
|
|
|
|
|
2018-11-27 06:23:04 +01:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2018-07-16 03:52:41 +02:00
|
|
|
|
2018-11-27 06:23:04 +01:00
|
|
|
cd "$NIX_BUILD_TOP"
|
2018-07-16 03:52:41 +02:00
|
|
|
|
2018-11-27 06:23:04 +01:00
|
|
|
emacs --batch -Q \
|
2018-11-25 22:19:50 +01:00
|
|
|
-L "$NIX_BUILD_TOP/package-build" \
|
2018-11-27 06:23:04 +01:00
|
|
|
-l "$melpa2nix" \
|
|
|
|
-f melpa2nix-build-package \
|
|
|
|
$ename $version
|
2018-07-16 03:52:41 +02:00
|
|
|
|
2018-11-27 06:23:04 +01:00
|
|
|
runHook postBuild
|
2018-07-16 03:52:41 +02:00
|
|
|
'';
|
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" ])
|