about summary refs log tree commit diff
path: root/emacs.nix
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-01-06T14·58+0000
committerWilliam Carroll <wpcarro@gmail.com>2020-01-17T10·56+0000
commit069ca630828435280cd41e30d3e75057180f333c (patch)
tree7d3e0d9f438386b9af284ea13412282abff8e319 /emacs.nix
parent7175d230c2cb2e5d90a25bcbd012ed75eaa96860 (diff)
WIP: Nixify Emacs setup
The things that I dislike about this setup are:
1. `xref-find-definitions` takes me to `/nix/store`, which is a read-only
version of the source code, so I cannot edit it, which doesn't feel lispy.

2. I need to rebuild the derivation when I change something, which also doesn't
feel lispy.

There are ways to circumvent both of these drawbacks, but for now, I'm checking
this in only to later revert it.
Diffstat (limited to 'emacs.nix')
-rw-r--r--emacs.nix141
1 files changed, 141 insertions, 0 deletions
diff --git a/emacs.nix b/emacs.nix
new file mode 100644
index 0000000000..8e3bf21d24
--- /dev/null
+++ b/emacs.nix
@@ -0,0 +1,141 @@
+{ pkgs ? import <nixpkgs> {}
+, tazjinsPkgs ? import (builtins.fetchGit "https://git.tazj.in") {
+    rev = "4c0e0d715f21eeb62594d198ba1eeccb1a2cfb13";
+  }
+}:
+
+let
+  # TODO: Move this function definition to a prelude.nix or elsewhere.
+  identity = x: x;
+
+  # Here is a whitelist of all of the binary dependencies that Emacs relies
+  # on. These are separate from Emacs libraries like dash.el.
+  emacsBinPath = pkgs.lib.strings.makeBinPath [ pkgs.terminator ];
+
+  emacsWithPackages = (pkgs.emacsPackagesNgGen pkgs.emacs26).emacsWithPackages;
+
+  # TODO: Learn more about melpa versus elpa to have a preference.
+  wpcarrosEmacs = emacsWithPackages (epkgs:
+    (with epkgs.elpaPackages; [
+      exwm
+    ]) ++
+
+    (with epkgs.melpaPackages; [
+      base16-theme
+      ivy-pass
+      clipmon # TODO: Prefer an Emacs client for clipmenud.
+      protobuf-mode # TODO: Determine if this is coming from google-emacs.
+      docker
+      evil
+      evil-collection
+      evil-magit
+      evil-leader
+      evil-commentary
+      evil-surround
+      key-chord
+      add-node-modules-path # TODO: Assess whether or not I need this with Nix.
+      web-mode
+      rjsx-mode
+      tide
+      prettier-js
+      flycheck
+      diminish
+      doom-themes
+      neotree # TODO: Remove this dependency from my config.
+      which-key
+      ivy
+      ivy-prescient
+      all-the-icons
+      all-the-icons-ivy
+      alert
+      nix-mode
+      racer
+      rust-mode
+      rainbow-delimiters
+      racket-mode
+      lispyville
+      elisp-slime-nav
+      py-yapf
+      reason-mode
+      elixir-mode
+      company
+      markdown-mode
+      refine
+      deferred
+      magit
+      request
+      pcre2el
+      helpful
+      exec-path-from-shell # TODO: Determine if Nix solves this problem.
+      yasnippet
+      projectile
+      deadgrep
+      counsel
+      counsel-projectile
+      engine-mode # TODO: Learn what this is.
+      eglot
+      dap-mode
+      lsp-ui
+      company-lsp
+      suggest
+      paradox
+      emr
+      flymake-shellcheck
+      fish-mode
+      tuareg
+      haskell-mode
+      lsp-haskell
+      use-package
+      general
+      clojure-mode
+      cider
+      f
+      dash
+      company
+      counsel
+      flycheck
+      ivy
+      magit
+    ]) ++
+
+    # tazjin's packages
+    (with tazjinsPkgs.tools.emacs-pkgs; [
+      dottime
+      term-switcher
+    ]));
+
+# TODO: Do I need `pkgs.lib.fix`?
+in pkgs.lib.fix(self: l: f: pkgs.writeShellScriptBin "wpcarros-emacs" ''
+   export PATH="${emacsBinPath}:$PATH"
+   exec ${wpcarrosEmacs}/bin/emacs \
+     --debug-init \
+     --no-site-file \
+     --no-site-lisp \
+     --directory ${ ./configs/shared/emacs.d/vendor } \
+     --directory ${ ./configs/shared/emacs.d/wpc } \
+     --directory ${ ./configs/shared/emacs.d/wpc/packages } \
+     --load ${ ./configs/shared/emacs.d/init.el } \
+     --no-init-file $@
+'' // {
+  # TODO: Ascertain whether I need this.
+  overrideEmacs = f': self l f';
+
+  # Call with a local.el file containing local system configuration.
+  withLocalConfig = confDir: self confDir f;
+
+  # This accepts the path to a non-Nix built Emacs, so that X and GL linkage
+  # behaves as expected.
+  withLocalEmacs = emacsBin: pkgs.writeShellScriptBin "wpcarros-emacs" ''
+    export PATH="${emacsBinPath}:$PATH"
+    export EMACSLOADPATH="${wpcarrosEmacs.deps}/share/emacs/site-lisp:"
+    exec ${emacsBin} \
+      --debug-init \
+      --no-site-file \
+      --no-site-lisp \
+      --directory ${ ./configs/shared/emacs.d/vendor } \
+      --directory ${ ./configs/shared/emacs.d/wpc } \
+      --directory ${ ./configs/shared/emacs.d/wpc/packages } \
+      --load ${ ./configs/shared/emacs.d/init.el } \
+      --no-init-file $@
+  '';
+}) null identity