about summary refs log tree commit diff
path: root/nix/writeElispBin/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix/writeElispBin/default.nix')
-rw-r--r--nix/writeElispBin/default.nix18
1 files changed, 18 insertions, 0 deletions
diff --git a/nix/writeElispBin/default.nix b/nix/writeElispBin/default.nix
new file mode 100644
index 0000000000..c116607e0a
--- /dev/null
+++ b/nix/writeElispBin/default.nix
@@ -0,0 +1,18 @@
+{ depot, pkgs, ... }:
+
+{ name, src, deps ? (_: []), emacs ? pkgs.emacs27-nox }:
+
+let
+  inherit (pkgs) emacsPackages emacsPackagesGen;
+  inherit (builtins) isString toFile;
+
+  finalEmacs = (emacsPackagesGen emacs).emacsWithPackages deps;
+
+  srcFile = if isString src
+    then toFile "${name}.el" src
+    else src;
+
+in depot.nix.writeScriptBin name ''
+  #!/bin/sh
+  ${finalEmacs}/bin/emacs --batch --no-site-file --script ${srcFile} $@
+''