about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/emacs/config/init.el11
-rw-r--r--tools/emacs/default.nix14
2 files changed, 17 insertions, 8 deletions
diff --git a/tools/emacs/config/init.el b/tools/emacs/config/init.el
index a23a16fca550..83621a99f9c1 100644
--- a/tools/emacs/config/init.el
+++ b/tools/emacs/config/init.el
@@ -170,10 +170,11 @@
 (telephone-line-setup)
 (ace-window-display-mode)
 
-;; If a local configuration file exists, it should be loaded. No
-;; other configuration comes from `user-emacs-directory'.
-(let ((local-file (expand-file-name (f-join user-emacs-directory "local.el"))))
-  (when (f-exists? local-file)
-    (load local-file)))
+;; If a local configuration library exists, it should be loaded.
+;;
+;; This can be provided by calling my Emacs derivation with
+;; `withLocalConfig'.
+(if-let (local-file (locate-library "local"))
+    (load local-file))
 
 (provide 'init)
diff --git a/tools/emacs/default.nix b/tools/emacs/default.nix
index 8d12bcb11dbf..8f036208e902 100644
--- a/tools/emacs/default.nix
+++ b/tools/emacs/default.nix
@@ -84,12 +84,20 @@ let
   # Custom packages
   [ carp-mode localPackages.dottime localPackages.term-switcher ]
   )));
-in lib.fix(self: f: third_party.writeShellScriptBin "tazjins-emacs" ''
+in lib.fix(self: l: f: third_party.writeShellScriptBin "tazjins-emacs" ''
   exec ${tazjinsEmacs f}/bin/emacs \
     --debug-init \
     --no-site-file \
     --no-site-lisp \
     --no-init-file \
-    --directory ${./config} \
+    --directory ${./config} ${if l != null then "--directory ${l}" else ""} \
     --eval "(require 'init)" $@
-  '' // { overrideEmacs = f': self f'; }) identity
+  '' // {
+    # Call overrideEmacs with a function (pkgs -> pkgs) to modify the
+    # packages that should be included in this Emacs distribution.
+    overrideEmacs = f': self l f';
+
+    # Call withLocalConfig with the path to a *folder* containing a
+    # `local.el` which provides local system configuration.
+    withLocalConfig = confDir: self confDir f;
+  }) null identity