about summary refs log tree commit diff
path: root/overrides/writeElispBin
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-12-20T20·37+0000
committerVincent Ambo <tazjin@google.com>2019-12-20T20·37+0000
commit8de5d093d8e35b2492c81015dcfcb052d2718614 (patch)
treef4bb5763a39c7059537fc7877e3c0ac15a4d8f69 /overrides/writeElispBin
parent03bfe08e1dd9faf48b06cb146bfa446575cde88a (diff)
refactor: Fix a variety of filepaths for repo relayouting r/238
This fixes readTree and the various project builds, as well
as (hopefully) most documentation links inside of the projects.
Diffstat (limited to 'overrides/writeElispBin')
-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..a1616fb9d464
--- /dev/null
+++ b/overrides/writeElispBin/default.nix
@@ -0,0 +1,23 @@
+{ pkgs, ... }:
+
+{ name, src, deps ? (_: []), emacs ? pkgs.third_party.emacs26-nox }:
+
+let
+  inherit (pkgs.third_party) 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} $@
+  '';
+}