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












                                                                         
{ pkgs, ... }:

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

let
  inherit (pkgs) emacsPackagesNg emacsPackagesNgGen writeTextFile;
  inherit (builtins) isString toFile;

  finalEmacs = (emacsPackagesNgGen 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} $@
  '';
}