about summary refs log blame commit diff
path: root/overrides/writeElispBin.nix
blob: 72871b9f0b43b0905814cf659ee339838a93962a (plain) (tree)






















                                                                         
{ pkgs, ... }:

{ name, src, deps ? (_: []), emacs ? pkgs.emacs26-nox }:

let
  inherit (pkgs) emacsPackagesFor writeTextFile;
  inherit (builtins) isString toFile;

  finalEmacs = (emacsPackagesFor emacs).emacsWithPackages deps;

  srcFile = if isString src
    then toFile "${name}.el" src
    else src;
in writeTextFile {
  inherit name;
  executable = true;
  destination = "/bin/${name}";

  text = ''
    #!/bin/sh
    ${finalEmacs}/bin/emacs --batch --no-site-file --script ${srcFile} $@
  '';
}