about summary refs log tree commit diff
path: root/overrides/writeElispBin/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'overrides/writeElispBin/default.nix')
-rw-r--r--overrides/writeElispBin/default.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/overrides/writeElispBin/default.nix b/overrides/writeElispBin/default.nix
new file mode 100644
index 000000000000..f2c81a2c0226
--- /dev/null
+++ b/overrides/writeElispBin/default.nix
@@ -0,0 +1,23 @@
+{ pkgs, ... }:
+
+{ name, src, deps ? (_: []), emacs ? pkgs.emacs26-nox }:
+
+let
+  inherit (pkgs) emacsPackages emacsPackagesGen writeTextFile;
+  inherit (builtins) isString toFile;
+
+  finalEmacs = (emacsPackagesGen 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} $@
+  '';
+}