diff options
Diffstat (limited to 'pkgs/build-support/emacs/melpa.nix')
-rw-r--r-- | pkgs/build-support/emacs/melpa.nix | 85 |
1 files changed, 46 insertions, 39 deletions
diff --git a/pkgs/build-support/emacs/melpa.nix b/pkgs/build-support/emacs/melpa.nix index 3b8a23d8c2a47..f55c91f82c7db 100644 --- a/pkgs/build-support/emacs/melpa.nix +++ b/pkgs/build-support/emacs/melpa.nix @@ -1,35 +1,19 @@ # builder for Emacs packages built for packages.el # using MELPA package-build.el -{ lib, stdenv, fetchurl, emacs, texinfo }: +{ lib, stdenv, fetchurl, fetchFromGitHub, emacs, texinfo }: with lib; { pname , version - -, recipeFile ? null - -, files ? null -, fileSpecs ? [ "*.el" "*.el.in" "dir" - "*.info" "*.texi" "*.texinfo" - "doc/dir" "doc/*.info" "doc/*.texi" "doc/*.texinfo" - ] - +, recipe , meta ? {} - , ... }@args: let - packageBuild = fetchurl { - url = https://raw.githubusercontent.com/milkypostman/melpa/2b3eb31c077fcaff94b74b757c1ce17650333943/package-build.el; - sha256 = "1biwg2pqmmdz5iwqbjdszljazqymvgyyjcnc255nr6qz8mhnx67j"; - }; - - targets = concatStringsSep " " (if files == null then fileSpecs else files); - defaultMeta = { homepage = args.src.meta.homepage or "http://melpa.org/#/${pname}"; }; @@ -37,33 +21,58 @@ let in import ./generic.nix { inherit lib stdenv emacs texinfo; } ({ - inherit packageBuild; - buildPhase = - if recipeFile == null - then '' - runHook preBuild + melpa = fetchFromGitHub { + owner = "melpa"; + repo = "melpa"; + rev = "7103313a7c31bb1ebb71419e365cd2e279ee4609"; + sha256 = "0m10f83ix0mzjk0vjd4kkb1m1p4b8ha0ll2yjsgk9bqjd7fwapqb"; + }; - export archive=$(emacs --batch -Q -l $packageBuild -l ${./melpa2nix.el} \ - -f melpa2nix-build-package \ - ${pname} ${version} ${targets}) + elpa2nix = ./elpa2nix.el; + melpa2nix = ./melpa2nix.el; - runHook postBuild - '' - else '' - runHook preBuild + preUnpack = '' + mkdir -p "$NIX_BUILD_TOP/recipes" + if [ -n "$recipe" ]; then + cp "$recipe" "$NIX_BUILD_TOP/recipes/$pname" + fi - export archive=$(emacs --batch -Q -l $packageBuild -l ${./melpa2nix.el} \ - -f melpa2nix-build-package-from-recipe \ - ${recipeFile} ${version}) + ln -s "$melpa/package-build" "$NIX_BUILD_TOP/package-build" - runHook postBuild - ''; + mkdir -p "$NIX_BUILD_TOP/packages" + ''; + + postUnpack = '' + mkdir -p "$NIX_BUILD_TOP/working" + ln -s "$NIX_BUILD_TOP/$sourceRoot" "$NIX_BUILD_TOP/working/$pname" + ''; + + buildPhase = + '' + runHook preBuild + + cd "$NIX_BUILD_TOP" + + emacs --batch -Q \ + -L "$melpa/package-build" \ + -l "$melpa2nix" \ + -f melpa2nix-build-package \ + $pname $version + + runHook postBuild + ''; installPhase = '' runHook preInstall - emacs --batch -Q -l ${./elpa2nix.el} \ + archive="$NIX_BUILD_TOP/packages/$pname-$version.el" + if [ ! -f "$archive" ]; then + archive="$NIX_BUILD_TOP/packages/$pname-$version.tar" + fi + + emacs --batch -Q \ + -l "$elpa2nix" \ -f elpa2nix-install-package \ "$archive" "$out/share/emacs/site-lisp/elpa" @@ -73,6 +82,4 @@ import ./generic.nix { inherit lib stdenv emacs texinfo; } ({ meta = defaultMeta // meta; } -// removeAttrs args [ "files" "fileSpecs" - "meta" - ]) +// removeAttrs args [ "meta" ]) |