2022-11-19 19:20:12 +01:00
|
|
|
# My Emacs distribution, which is supporting the following platforms:
|
|
|
|
# - Linux
|
|
|
|
# - Darwin
|
|
|
|
#
|
|
|
|
# USAGE:
|
2022-11-21 04:20:26 +01:00
|
|
|
# $ nix-build -A users.wpcarro.emacs.osx -o /Applications/BillsEmacs.app
|
2022-01-18 21:06:26 +01:00
|
|
|
{ depot, pkgs, lib, ... }:
|
2020-01-06 15:58:22 +01:00
|
|
|
|
2021-12-20 03:58:40 +01:00
|
|
|
# TODO(wpcarro): See if it's possible to expose emacsclient on PATH, so that I
|
|
|
|
# don't need to depend on wpcarros-emacs and emacs in my NixOS configurations.
|
2020-01-06 15:58:22 +01:00
|
|
|
let
|
2022-04-21 16:36:04 +02:00
|
|
|
inherit (depot.third_party.nixpkgs) emacsPackagesFor emacs28;
|
2021-12-25 00:44:36 +01:00
|
|
|
inherit (depot.users) wpcarro;
|
2022-01-18 21:06:26 +01:00
|
|
|
inherit (lib) mapAttrsToList;
|
|
|
|
inherit (lib.strings) concatStringsSep makeBinPath;
|
2022-01-28 07:21:37 +01:00
|
|
|
inherit (pkgs) runCommand writeShellScriptBin;
|
2020-08-31 12:31:00 +02:00
|
|
|
|
2021-12-25 00:44:36 +01:00
|
|
|
emacsBinPath = makeBinPath (
|
|
|
|
wpcarro.common.shell-utils ++
|
2022-08-08 19:53:23 +02:00
|
|
|
# Rust dependencies
|
|
|
|
(with pkgs; [
|
|
|
|
cargo
|
|
|
|
rust-analyzer
|
|
|
|
rustc
|
|
|
|
rustfmt
|
|
|
|
]) ++
|
|
|
|
# Misc dependencies
|
2021-12-25 00:44:36 +01:00
|
|
|
(with pkgs; [
|
|
|
|
ispell
|
|
|
|
nix
|
2022-08-07 21:50:29 +02:00
|
|
|
rust-analyzer
|
2022-08-07 06:17:06 +02:00
|
|
|
rustc
|
|
|
|
rustfmt
|
2022-11-21 04:20:26 +01:00
|
|
|
xorg.xset
|
2022-11-19 19:20:12 +01:00
|
|
|
] ++
|
|
|
|
(if pkgs.stdenv.isLinux then [
|
2021-12-25 00:44:36 +01:00
|
|
|
scrot
|
2022-11-19 19:20:12 +01:00
|
|
|
] else [ ]))
|
2021-12-25 00:44:36 +01:00
|
|
|
);
|
2020-04-02 15:37:47 +02:00
|
|
|
|
2022-04-21 16:36:04 +02:00
|
|
|
emacsWithPackages = (emacsPackagesFor emacs28).emacsWithPackages;
|
2020-04-02 15:37:47 +02:00
|
|
|
|
2020-01-06 15:58:22 +01:00
|
|
|
wpcarrosEmacs = emacsWithPackages (epkgs:
|
2022-07-22 04:55:39 +02:00
|
|
|
(with wpcarro.emacs.pkgs; [
|
2022-07-29 05:29:07 +02:00
|
|
|
al
|
2022-11-25 06:50:52 +01:00
|
|
|
bookmark
|
2022-07-30 06:12:59 +02:00
|
|
|
cycle
|
2022-07-29 05:29:07 +02:00
|
|
|
list
|
2022-11-25 07:35:29 +01:00
|
|
|
macros
|
2022-07-29 20:15:17 +02:00
|
|
|
maybe
|
2022-12-11 22:33:29 +01:00
|
|
|
passage
|
2022-07-29 05:29:07 +02:00
|
|
|
set
|
2022-07-30 03:56:06 +02:00
|
|
|
string
|
2022-07-29 05:29:07 +02:00
|
|
|
struct
|
2022-07-30 19:43:06 +02:00
|
|
|
symbol
|
2022-11-25 19:36:02 +01:00
|
|
|
theme
|
2022-11-25 07:19:02 +01:00
|
|
|
tuple
|
2022-07-30 20:19:43 +02:00
|
|
|
vterm-mgt
|
2022-07-22 04:55:39 +02:00
|
|
|
zle
|
|
|
|
]) ++
|
|
|
|
|
2021-12-16 06:13:47 +01:00
|
|
|
(with epkgs.tvlPackages; [
|
|
|
|
tvl
|
|
|
|
]) ++
|
|
|
|
|
2020-01-06 15:58:22 +01:00
|
|
|
(with epkgs.elpaPackages; [
|
|
|
|
exwm
|
|
|
|
]) ++
|
|
|
|
|
|
|
|
(with epkgs.melpaPackages; [
|
2022-11-25 18:54:57 +01:00
|
|
|
alert
|
|
|
|
all-the-icons
|
|
|
|
all-the-icons-ivy
|
2022-02-13 20:04:54 +01:00
|
|
|
avy
|
2020-01-06 15:58:22 +01:00
|
|
|
base16-theme
|
2022-11-25 18:54:57 +01:00
|
|
|
cider
|
|
|
|
clojure-mode
|
|
|
|
company
|
|
|
|
counsel
|
|
|
|
counsel-projectile
|
2022-05-09 17:17:21 +02:00
|
|
|
csharp-mode
|
2022-11-25 18:54:57 +01:00
|
|
|
dap-mode
|
|
|
|
dash
|
|
|
|
deadgrep
|
|
|
|
deferred
|
|
|
|
diminish
|
|
|
|
direnv
|
2022-04-15 19:34:00 +02:00
|
|
|
dockerfile-mode
|
2023-12-06 11:30:39 +01:00
|
|
|
# TODO(wpcarro): broken since channel bump cl/10204
|
|
|
|
# doom-themes
|
2022-11-25 18:54:57 +01:00
|
|
|
elisp-slime-nav
|
|
|
|
elixir-mode
|
|
|
|
elm-mode
|
|
|
|
emojify
|
|
|
|
engine-mode
|
2020-01-06 15:58:22 +01:00
|
|
|
evil
|
|
|
|
evil-collection
|
|
|
|
evil-commentary
|
|
|
|
evil-surround
|
2022-11-25 18:54:57 +01:00
|
|
|
f
|
|
|
|
fish-mode
|
2020-01-06 15:58:22 +01:00
|
|
|
flycheck
|
2022-11-25 18:54:57 +01:00
|
|
|
flymake-shellcheck
|
|
|
|
general
|
|
|
|
go-mode
|
|
|
|
haskell-mode
|
|
|
|
helpful
|
2020-01-06 15:58:22 +01:00
|
|
|
ivy
|
2022-02-14 22:55:20 +01:00
|
|
|
ivy-clipmenu
|
2020-11-12 12:20:27 +01:00
|
|
|
ivy-prescient
|
2022-11-25 18:54:57 +01:00
|
|
|
key-chord
|
|
|
|
lispyville
|
|
|
|
lsp-ui
|
|
|
|
magit
|
2020-01-31 13:45:48 +01:00
|
|
|
magit-popup
|
2022-11-25 18:54:57 +01:00
|
|
|
markdown-mode
|
2020-01-06 15:58:22 +01:00
|
|
|
nix-mode
|
2022-11-25 18:54:57 +01:00
|
|
|
notmuch
|
|
|
|
org-bullets
|
|
|
|
package-lint
|
|
|
|
paradox
|
|
|
|
parsec
|
|
|
|
pcre2el
|
|
|
|
prettier-js
|
|
|
|
projectile
|
2020-01-06 15:58:22 +01:00
|
|
|
py-yapf
|
2022-11-25 18:54:57 +01:00
|
|
|
racket-mode
|
|
|
|
rainbow-delimiters
|
2020-01-06 15:58:22 +01:00
|
|
|
reason-mode
|
|
|
|
refine
|
|
|
|
request
|
2022-11-25 18:54:57 +01:00
|
|
|
restclient
|
|
|
|
rjsx-mode
|
|
|
|
rust-mode
|
|
|
|
sly
|
2020-01-06 15:58:22 +01:00
|
|
|
suggest
|
2022-11-25 18:54:57 +01:00
|
|
|
telephone-line
|
|
|
|
terraform-mode
|
|
|
|
tide
|
|
|
|
ts
|
2020-01-06 15:58:22 +01:00
|
|
|
tuareg
|
|
|
|
use-package
|
2022-11-25 18:54:57 +01:00
|
|
|
vterm
|
|
|
|
web-mode
|
|
|
|
which-key
|
2022-04-15 19:34:00 +02:00
|
|
|
yaml-mode
|
2022-11-25 18:54:57 +01:00
|
|
|
yasnippet
|
2023-03-18 22:34:19 +01:00
|
|
|
]) ++
|
|
|
|
|
|
|
|
[
|
|
|
|
epkgs.eglot # from elpa devel
|
|
|
|
]);
|
2020-01-06 15:58:22 +01:00
|
|
|
|
2020-09-07 11:52:54 +02:00
|
|
|
loadPath = concatStringsSep ":" [
|
2022-01-28 07:15:40 +01:00
|
|
|
./.emacs.d/wpc
|
2021-12-25 16:37:18 +01:00
|
|
|
# TODO(wpcarro): Explain why the trailing ":" is needed.
|
2020-09-07 11:52:54 +02:00
|
|
|
"${wpcarrosEmacs.deps}/share/emacs/site-lisp:"
|
|
|
|
];
|
|
|
|
|
2022-01-18 21:06:26 +01:00
|
|
|
# Transform an attrset into "export k=v" statements.
|
|
|
|
makeEnvVars = env: concatStringsSep "\n"
|
|
|
|
(mapAttrsToList (k: v: "export ${k}=\"${v}\"") env);
|
|
|
|
|
2022-01-28 07:21:37 +01:00
|
|
|
withEmacsPath = { emacsBin, env ? { }, load ? [ ] }:
|
2020-08-31 12:31:00 +02:00
|
|
|
writeShellScriptBin "wpcarros-emacs" ''
|
2020-08-31 02:16:31 +02:00
|
|
|
export XMODIFIERS=emacs
|
|
|
|
export PATH="${emacsBinPath}:$PATH"
|
2020-09-07 11:52:54 +02:00
|
|
|
export EMACSLOADPATH="${loadPath}"
|
2022-01-18 21:06:26 +01:00
|
|
|
${makeEnvVars env}
|
2020-08-31 02:16:31 +02:00
|
|
|
exec ${emacsBin} \
|
|
|
|
--debug-init \
|
2020-11-12 12:20:27 +01:00
|
|
|
--no-init-file \
|
2020-08-31 02:16:31 +02:00
|
|
|
--no-site-file \
|
|
|
|
--no-site-lisp \
|
2022-01-28 07:15:40 +01:00
|
|
|
--load ${./.emacs.d/init.el} \
|
2022-01-31 21:58:04 +01:00
|
|
|
${concatStringsSep "\n " (map (el: "--load ${el} \\") load)}
|
2020-08-31 02:16:31 +02:00
|
|
|
"$@"
|
|
|
|
'';
|
2022-11-21 04:20:26 +01:00
|
|
|
|
|
|
|
# I can't figure out how to augment LSEnvironment.PATH such that it inherits
|
|
|
|
# the default $PATH and adds the things that I need as well, so let's
|
|
|
|
# hardcode the desired outcome in the meantime.
|
|
|
|
osxDefaultPath = builtins.concatStringsSep ":" [
|
|
|
|
"/Users/bill/.nix-profile/bin"
|
|
|
|
"/nix/var/nix/profiles/default/bin"
|
|
|
|
"/opt/homebrew/bin"
|
|
|
|
"/opt/homebrew/sbin"
|
|
|
|
"/usr/local/bin"
|
|
|
|
"/usr/bin"
|
|
|
|
"/bin"
|
|
|
|
"/usr/sbin"
|
|
|
|
"/sbin"
|
|
|
|
"/opt/X11/bin"
|
|
|
|
];
|
|
|
|
|
|
|
|
infoPlist = pkgs.writeText "Info.plist" (pkgs.lib.generators.toPlist { } {
|
|
|
|
LSEnvironment = {
|
|
|
|
PATH = "${emacsBinPath}:${osxDefaultPath}";
|
|
|
|
};
|
|
|
|
CFBundleExecutable = "BillsEmacs";
|
|
|
|
CFBundleDisplayName = "BillsEmacs";
|
|
|
|
CFBundleIconFile = "AppIcon";
|
|
|
|
CFBundleIconName = "AppIcon";
|
|
|
|
});
|
|
|
|
|
|
|
|
versionPlist = pkgs.writeText "version.plist" (pkgs.lib.generators.toPlist { } {
|
|
|
|
ProjectName = "OSXPlatformSupport";
|
|
|
|
});
|
2022-01-28 20:55:27 +01:00
|
|
|
in
|
2022-11-21 04:20:26 +01:00
|
|
|
{
|
2022-11-19 19:20:12 +01:00
|
|
|
# TODO(wpcarro): Support this with base.overrideAttrs or something similar.
|
2022-01-28 07:21:37 +01:00
|
|
|
nixos = { load ? [ ] }: withEmacsPath {
|
|
|
|
inherit load;
|
2020-08-31 02:16:31 +02:00
|
|
|
emacsBin = "${wpcarrosEmacs}/bin/emacs";
|
|
|
|
};
|
2021-12-24 00:30:31 +01:00
|
|
|
|
2022-11-21 04:20:26 +01:00
|
|
|
# To install GUI:
|
|
|
|
# $ nix-build -A users.wpcarro.emacs.osx -o /Applications/BillsEmacs.app
|
|
|
|
osx = pkgs.stdenv.mkDerivation {
|
|
|
|
pname = "bills-emacs";
|
|
|
|
version = "0.0.1";
|
|
|
|
src = ./.;
|
|
|
|
dontFixup = true;
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
APP="$out"
|
|
|
|
mkdir -p "$APP/Contents/MacOS"
|
|
|
|
mkdir -p "$APP/Contents/Resources"
|
|
|
|
cp ${infoPlist} "$APP/Contents/Info.plist"
|
|
|
|
cp ${versionPlist} "$APP/Contents/version.plist"
|
|
|
|
cp ${./AppIcon.icns} "$APP/Contents/Resources/AppIcon.icns"
|
|
|
|
echo "APPL????" > "$APP/Contents/PkgInfo"
|
|
|
|
cat << EOF > "$APP/Contents/MacOS/BillsEmacs"
|
|
|
|
#!${pkgs.stdenvNoCC.shell}
|
|
|
|
export EMACSLOADPATH="${loadPath}"
|
|
|
|
exec ${wpcarrosEmacs}/bin/emacs \
|
|
|
|
--debug-init \
|
|
|
|
--no-init-file \
|
|
|
|
--no-site-file \
|
|
|
|
--no-site-lisp \
|
|
|
|
--load ${./.emacs.d/init.el}
|
|
|
|
EOF
|
|
|
|
chmod +x "$APP/Contents/MacOS/BillsEmacs"
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
meta.platforms = [ "aarch64-darwin" ];
|
|
|
|
};
|
2022-11-19 19:20:12 +01:00
|
|
|
|
2022-01-28 21:40:11 +01:00
|
|
|
# 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
|
|
|
|
# this locally without depending on my ability to remember to set CI=true.
|
|
|
|
export CI=true
|
|
|
|
export PATH="${emacsBinPath}:$PATH"
|
|
|
|
export EMACSLOADPATH="${loadPath}"
|
|
|
|
${wpcarrosEmacs}/bin/emacs \
|
|
|
|
--no-site-file \
|
|
|
|
--no-site-lisp \
|
|
|
|
--no-init-file \
|
|
|
|
--script ${./ci.el} \
|
|
|
|
${./.emacs.d/init.el} && \
|
|
|
|
touch $out
|
|
|
|
'';
|
2022-11-21 04:20:26 +01:00
|
|
|
|
2023-12-06 11:30:39 +01:00
|
|
|
# TODO(wpcarro): commented out because of doom-themes breakage; cl/10204
|
|
|
|
# meta.ci.targets = [ "check" ];
|
2020-04-02 15:37:47 +02:00
|
|
|
}
|