fix(wpcarro/emacs): Support OSX build of Emacs

**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>
This commit is contained in:
William Carroll 2022-11-19 10:20:12 -08:00 committed by clbot
parent 932c3b31bb
commit 3d8849e68b
6 changed files with 49 additions and 96 deletions

View file

@ -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" ];
}