about summary refs log tree commit diff
path: root/overrides/writeElispBin.nix
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-12-09T02·20+0000
committerVincent Ambo <tazjin@google.com>2019-12-09T02·20+0000
commit688233acac967178588943061992455b91cbda03 (patch)
tree951542817e321d0ab7ffe07f87809341833e9710 /overrides/writeElispBin.nix
parent608a560ee80af290685e8bd96d072e86e6b08320 (diff)
feat: Add writeElispBin helper function r/99
Exactly as the name suggests. Currently, passing arguments from the
CLI is not really supported.
Diffstat (limited to 'overrides/writeElispBin.nix')
-rw-r--r--overrides/writeElispBin.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/overrides/writeElispBin.nix b/overrides/writeElispBin.nix
new file mode 100644
index 000000000000..72871b9f0b43
--- /dev/null
+++ b/overrides/writeElispBin.nix
@@ -0,0 +1,23 @@
+{ 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} $@
+  '';
+}