about summary refs log blame commit diff
path: root/overrides/writeElispBin.nix
blob: abd39343dd911bcc1f39ea03c9aeef3305f8034b (plain) (tree)
1
2
3
4
5
6

              
                                                                    

   
                                                            
















                                                                         
{ pkgs, ... }:

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

let
  inherit (pkgs.third_party) 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} $@
  '';
}