summary refs log tree commit diff
path: root/pkgs/build-support/emacs/melpa.nix
blob: 3b8a23d8c2a472e3fa11a3c724a9418b8ece9607 (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
68
69
70
71
72
73
74
75
76
77
78
# builder for Emacs packages built for packages.el
# using MELPA package-build.el

{ lib, stdenv, fetchurl, 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"
              ]

, 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}";
  };

in

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

  buildPhase =
    if recipeFile == null
      then ''
        runHook preBuild

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

        runHook postBuild
      ''
      else ''
        runHook preBuild

        export archive=$(emacs --batch -Q -l $packageBuild -l ${./melpa2nix.el} \
            -f melpa2nix-build-package-from-recipe \
            ${recipeFile} ${version})

        runHook postBuild
      '';

  installPhase = ''
    runHook preInstall

    emacs --batch -Q -l ${./elpa2nix.el} \
        -f elpa2nix-install-package \
        "$archive" "$out/share/emacs/site-lisp/elpa"

    runHook postInstall
  '';

  meta = defaultMeta // meta;
}

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