nftable-migration
 1{
 2  stdenv,
 3  lib,
 4  emacs,
 5  name,
 6  src,
 7  buildInputs ? [ ],
 8  patches ? [ ],
 9  preBuild ? "",
10}:
11
12stdenv.mkDerivation {
13  inherit name src patches;
14  unpackCmd = ''
15    test -f "${src}" && mkdir el && cp -p ${src} el/${name}
16  '';
17  buildInputs = [ emacs ] ++ buildInputs;
18  buildPhase = ''
19    ${preBuild}
20    ARGS=$(find ${lib.concatStrings (builtins.map (arg: arg + "/share/emacs/site-lisp ") buildInputs)} \
21                 -type d -exec echo -L {} \;)
22    mkdir $out
23    export HOME=$out
24    ${emacs}/bin/emacs -Q -nw -L . $ARGS --batch -f batch-byte-compile *.el
25  '';
26  installPhase = ''
27    mkdir -p $out/share/emacs/site-lisp
28    install *.el* $out/share/emacs/site-lisp
29  '';
30  meta = {
31    description = "Emacs projects from the Internet that just compile .el files";
32    homepage = "http://www.emacswiki.org";
33    platforms = lib.platforms.all;
34  };
35}