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