summary refs log tree commit diff
path: root/pkgs/applications/editors/emacs-modes/elpa-packages.nix
blob: 3cf37c2628068e86b4599036186cef02882919f5 (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
pkgs: with pkgs;

let

  inherit (stdenv.lib) makeScope mapAttrs;

  json = builtins.readFile ./elpa-packages.json;
  manifest = builtins.fromJSON json;

  mkPackage = self: name: recipe:
    let drv =
          { elpaBuild, stdenv, fetchurl }:
          let fetch = { inherit fetchurl; }."${recipe.fetch.tag}"
                or (abort "emacs-${name}: unknown fetcher '${recipe.fetch.tag}'");
              args = builtins.removeAttrs recipe.fetch [ "tag" ];
              src = fetch args;
          in elpaBuild {
            pname = name;
            inherit (recipe) version;
            inherit src;
            deps =
              let lookupDep = d:
                    self."${d}" or (abort "emacs-${name}: missing dependency ${d}");
              in map lookupDep recipe.deps;
            meta = {
              homepage = "http://elpa.gnu.org/packages/${name}.html";
              license = stdenv.lib.licenses.free;
            };
          };
    in self.callPackage drv {};

  packages = self:
    let
      elpaPackages = mapAttrs (mkPackage self) manifest;

      elpaBuild = import ../../../build-support/emacs/melpa.nix {
        inherit (pkgs) lib stdenv fetchurl texinfo;
        inherit (self) emacs;
      };
    in elpaPackages // { inherit elpaBuild elpaPackages; };

in makeScope pkgs.newScope packages