about summary refs log tree commit diff
path: root/users/wpcarro/emacs/default.nix
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2022-11-19T18·20-0800
committerclbot <clbot@tvl.fyi>2022-11-19T19·36+0000
commit3d8849e68bc198efeb8a179a4bcf32771d7967fe (patch)
tree3204ba6d59d59c63b59dc660c111c32ea253f91b /users/wpcarro/emacs/default.nix
parent932c3b31bbb16b5d52d34fd65c51d2bd59f94762 (diff)
fix(wpcarro/emacs): Support OSX build of Emacs r/5291
**TL;DR:**
Most of these changes predicate behavior on the platform:
- At buildtime this is `localSystem == $something`. (`localSystem` is from
  `readTree`)
- At runtime this is `(memq window-system '(ns))`.
- Add `coreutils` so `dired` listing with `--group-directories-first` works
  because that flag depends on the GNU version of `ls`.

**Background:**
I need to support a bunch of OSX users at $WORK. As such, I'm planning
on using my MBP for the next few weeks to build empathy for our
userbase and polish some currently rough edges.

If I'm going to get an serious work done, I need my Emacs setup. Step
one is making sure it can build and run.

Change-Id: I918efccfa5f149e218aeea476c2c7df1c7b64ae8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7309
Autosubmit: wpcarro <wpcarro@gmail.com>
Tested-by: BuildkiteCI
Reviewed-by: wpcarro <wpcarro@gmail.com>
Diffstat (limited to 'users/wpcarro/emacs/default.nix')
-rw-r--r--users/wpcarro/emacs/default.nix31
1 files changed, 23 insertions, 8 deletions
diff --git a/users/wpcarro/emacs/default.nix b/users/wpcarro/emacs/default.nix
index 3ca65c292e2c..2fe879583d22 100644
--- a/users/wpcarro/emacs/default.nix
+++ b/users/wpcarro/emacs/default.nix
@@ -1,3 +1,9 @@
+# My Emacs distribution, which is supporting the following platforms:
+# - Linux
+# - Darwin
+#
+# USAGE:
+#   $ mg build //users/wpcarro/emacs:osx
 { depot, pkgs, lib, ... }:
 
 # TODO(wpcarro): See if it's possible to expose emacsclient on PATH, so that I
@@ -26,9 +32,11 @@ let
       rust-analyzer
       rustc
       rustfmt
+    ] ++
+    (if pkgs.stdenv.isLinux then [
       scrot
       xorg.xset
-    ])
+    ] else [ ]))
   );
 
   emacsWithPackages = (emacsPackagesFor emacs28).emacsWithPackages;
@@ -114,8 +122,6 @@ let
       request
       pcre2el
       helpful
-      # TODO(wpcarro): Determine if Nix solves this problem.
-      exec-path-from-shell
       yasnippet
       projectile
       deadgrep
@@ -171,14 +177,25 @@ let
         "$@"
     '';
 in
-{
-  inherit withEmacsPath;
-
+depot.nix.readTree.drvTargets {
+  # TODO(wpcarro): Support this with base.overrideAttrs or something similar.
   nixos = { load ? [ ] }: withEmacsPath {
     inherit load;
     emacsBin = "${wpcarrosEmacs}/bin/emacs";
   };
 
+  osx = writeShellScriptBin "wpcarros-emacs" ''
+    export PATH="${emacsBinPath}:$PATH"
+    export EMACSLOADPATH="${loadPath}"
+    exec ${wpcarrosEmacs}/bin/emacs \
+      --debug-init \
+      --no-init-file \
+      --no-site-file \
+      --no-site-lisp \
+      --load ${./.emacs.d/init.el} \
+      "$@"
+  '';
+
   # Script that asserts my Emacs can initialize without warnings or errors.
   check = runCommand "check-emacs" { } ''
     # Even though Buildkite defines this, I'd still like still be able to test
@@ -194,6 +211,4 @@ in
       ${./.emacs.d/init.el} && \
     touch $out
   '';
-
-  meta.ci.targets = [ "check" ];
 }