summaryrefslogtreecommitdiff
path: root/overlays/emacs/builder.nix
blob: 8c3349c710687491fbdeebbfb9c2a8ce61bda0d5 (plain)
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
# https://github.com/jwiegley/nix-config/blob/4d296ad/overlays/emacs/builder.nix
{ stdenv
, emacs
, name
, src
, buildInputs ? []
, patches ? []
, preBuild ? ""
}:

stdenv.mkDerivation {
  inherit name src patches;
  unpackCmd = ''
    test -f "${src}" && mkdir el && cp -p ${src} el/${name}
  '';
  buildInputs = [ emacs ] ++ buildInputs;
  buildPhase = ''
    ${preBuild}
    ARGS=$(find ${stdenv.lib.concatStrings
                  (builtins.map (arg: arg + "/share/emacs/site-lisp ") buildInputs)} \
                  -type -d -exec -L {} \;)
    ${emacs}/bin/emacs -Q -nw -L . ${ARGS} --batch -f batch-byte-compile *.el
  '';
  installPhase = ''
    mkdir -p ${out}/share/emacs/site-lisp
    install *.el* ${out/share/emacs/site-lisp
  '';
  meta = {
    description = "Emacs projects from the Internet that just compile `.el` files";
    homepage = http://www.emacswiki.org;
    platforms = stdenv.lib.platforms.all;
  };
}