summary refs log tree commit diff
path: root/pkgs/build-support/emacs/melpa.nix
blob: 607a1b4a5ef61779f0a061e3a73456bd5965b15a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# builder for Emacs packages built for packages.el
# using MELPA package-build.el

{ lib, stdenv, fetchurl, emacs, texinfo }:

with lib;

{ pname
, version

, files ? null
, fileSpecs ? [ "*.el" "*.el.in" "dir"
                "*.info" "*.texi" "*.texinfo"
                "doc/dir" "doc/*.info" "doc/*.texi" "doc/*.texinfo"
              ]

, meta ? {}

, ...
}@args:

let

  packageBuild = fetchurl {
    url = https://raw.githubusercontent.com/milkypostman/melpa/12a862e5c5c62ce627dab83d7cf2cca6e8b56c47/package-build.el;
    sha256 = "1nviyyprypz7nmam9rwli4yv3kxh170glfbznryrp4czxkrjjdhk";
  };

  fname = "${pname}-${version}";

  targets = concatStringsSep " " (if files == null then fileSpecs else files);

  defaultMeta = {
    homepage = "http://melpa.org/#/${pname}";
  };

in

import ./generic.nix { inherit lib stdenv emacs texinfo; } ({
  inherit packageBuild;

  buildPhase = ''
    runHook preBuild

    emacs --batch -Q -l $packageBuild -l ${./melpa2nix.el} \
      -f melpa2nix-build-package \
      ${pname} ${version} ${targets}

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    emacs --batch -Q -l $packageBuild -l ${./melpa2nix.el} \
      -f melpa2nix-install-package \
      ${fname}.* $out/share/emacs/site-lisp/elpa

    runHook postInstall
  '';

  meta = defaultMeta // meta;
}

// removeAttrs args [ "files" "fileSpecs"
                      "meta"
                    ])