2024-05-02 00:46:19 +00:00
|
|
|
# builder for Emacs packages built for packages.el
|
|
|
|
# using MELPA package-build.el
|
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
fetchFromGitHub,
|
|
|
|
emacs,
|
|
|
|
texinfo,
|
|
|
|
writeText,
|
|
|
|
gcc,
|
|
|
|
}:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
let
|
2024-06-30 08:12:46 +00:00
|
|
|
genericBuild = import ./generic.nix {
|
|
|
|
inherit
|
|
|
|
lib
|
|
|
|
stdenv
|
|
|
|
emacs
|
|
|
|
texinfo
|
|
|
|
writeText
|
|
|
|
gcc
|
|
|
|
;
|
|
|
|
};
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
packageBuild = stdenv.mkDerivation {
|
|
|
|
name = "package-build";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "melpa";
|
|
|
|
repo = "package-build";
|
|
|
|
rev = "c48aa078c01b4f07b804270c4583a0a58ffea1c0";
|
|
|
|
sha256 = "sha256-MzPj375upIiYXdQR+wWXv3A1zMqbSrZlH0taLuxx/1M=";
|
|
|
|
};
|
|
|
|
|
|
|
|
patches = [ ./package-build-dont-use-mtime.patch ];
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
installPhase = "
|
|
|
|
mkdir -p $out
|
|
|
|
cp -r * $out
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
{
|
|
|
|
/*
|
2024-05-02 00:46:19 +00:00
|
|
|
pname: Nix package name without special symbols and without version or
|
|
|
|
"emacs-" prefix.
|
|
|
|
*/
|
2024-06-30 08:12:46 +00:00
|
|
|
pname,
|
|
|
|
# ename: Original Emacs package name, possibly containing special symbols.
|
|
|
|
ename ? null,
|
|
|
|
version,
|
|
|
|
recipe,
|
|
|
|
meta ? { },
|
|
|
|
...
|
2024-05-02 00:46:19 +00:00
|
|
|
}@args:
|
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
genericBuild (
|
|
|
|
{
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
ename = if ename == null then pname else ename;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
elpa2nix = ./elpa2nix.el;
|
|
|
|
melpa2nix = ./melpa2nix.el;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
inherit packageBuild;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
preUnpack = ''
|
|
|
|
mkdir -p "$NIX_BUILD_TOP/recipes"
|
|
|
|
if [ -n "$recipe" ]; then
|
|
|
|
cp "$recipe" "$NIX_BUILD_TOP/recipes/$ename"
|
|
|
|
fi
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
ln -s "$packageBuild" "$NIX_BUILD_TOP/package-build"
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
mkdir -p "$NIX_BUILD_TOP/packages"
|
|
|
|
'';
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
postUnpack = ''
|
|
|
|
mkdir -p "$NIX_BUILD_TOP/working"
|
|
|
|
ln -s "$NIX_BUILD_TOP/$sourceRoot" "$NIX_BUILD_TOP/working/$ename"
|
|
|
|
'';
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
cd "$NIX_BUILD_TOP"
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
emacs --batch -Q \
|
|
|
|
-L "$NIX_BUILD_TOP/package-build" \
|
|
|
|
-l "$melpa2nix" \
|
|
|
|
-f melpa2nix-build-package \
|
|
|
|
$ename $version $commit
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
runHook postBuild
|
2024-05-02 00:46:19 +00:00
|
|
|
'';
|
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
archive="$NIX_BUILD_TOP/packages/$ename-$version.el"
|
|
|
|
if [ ! -f "$archive" ]; then
|
|
|
|
archive="$NIX_BUILD_TOP/packages/$ename-$version.tar"
|
|
|
|
fi
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
emacs --batch -Q \
|
|
|
|
-l "$elpa2nix" \
|
|
|
|
-f elpa2nix-install-package \
|
|
|
|
"$archive" "$out/share/emacs/site-lisp/elpa"
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
meta = {
|
|
|
|
homepage = args.src.meta.homepage or "https://melpa.org/#/${pname}";
|
|
|
|
} // meta;
|
|
|
|
}
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
// removeAttrs args [ "meta" ]
|
|
|
|
)
|