all repos — nixfiles @ c2c5e04d53ba91e22cf43ac42a54fb0606fb9465

System and user configuration, managed by nix and home-manager

emacs: native-compile init.el ahead of time
Alan Pearce alan@alanpearce.eu
Tue, 25 Apr 2023 23:12:51 +0200
commit

c2c5e04d53ba91e22cf43ac42a54fb0606fb9465

parent

9389e4954b12c12b2f020236bd6642f238ec8c9b

1 files changed, 7 insertions(+), 3 deletions(-)

jump to
M user/settings/emacs.nixuser/settings/emacs.nix
@@ -6,6 +6,8 @@ }: let
   inherit (pkgs) stdenv;
 
+  nativeCompileDirectory = "${config.xdg.cacheHome}/emacs/native-compile/";
+
   darwinPath = pkgs.runCommandLocal "path_helper " { } ''
     eval $(/usr/libexec/path_helper)
     echo -n $PATH > $out
@@ -165,7 +167,9 @@ (with-eval-after-load 'files         (setq insert-directory-program "${pkgs.coreutils-prefixed}/bin/gls"))
       (with-eval-after-load 'dired
         (setq dired-use-ls-dired t))
-      (setq exec-path (parse-colon-path (setenv "PATH" "${pkgs.clang}/bin:${pkgs.gcc}/bin:${pkgs.lib.readFile darwinPath}")))
+      (setq exec-path (parse-colon-path (setenv "PATH" "${pkgs.lib.readFile darwinPath}"))
+            native-compile-target-directory "${nativeCompileDirectory}")
+      (add-to-list 'native-comp-eln-load-path "${nativeCompileDirectory}" :append)
     '';
   };
   home.packages = [
@@ -174,13 +178,13 @@ ];   xdg.configFile."emacs/early-init.el" = {
     source = ../emacs/early-init.el;
     onChange = ''
-      ${config.programs.emacs.finalPackage}/bin/emacs -Q -batch -f batch-byte-compile .config/emacs/early-init.el
+      PATH="$PATH:/usr/libexec/DeveloperTools/" ${config.programs.emacs.finalPackage}/bin/emacs --batch --funcall batch-native-compile .config/emacs/early-init.el
     '';
   };
   xdg.configFile."emacs/init.el" = {
     source = ../emacs/init.el;
     onChange = ''
-      ${config.programs.emacs.finalPackage}/bin/emacs -Q -batch -f batch-byte-compile .config/emacs/init.el
+      PATH="$PATH:/usr/libexec/DeveloperTools/" ${config.programs.emacs.finalPackage}/bin/emacs --batch --funcall batch-native-compile .config/emacs/init.el
     '';
   };