about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-04-02T13·37+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-04-02T13·37+0100
commit401ec6a7a15041341124308197b726c4f908d97c (patch)
treeef0678951089a0d94dd35f23a821de0df22cd99a
parent8c3bf2debf2ad80c9583c16cffeb44e7333d1a2f (diff)
Tidy up emacs/default.nix
When I run `nix-env -f '<briefcase>' -iA emacs`, Nix builds a derivation of
wpcarros-emacs using the path to the Emacs derivation. This doesn't work well on
glinux and causes strange behavior. For instance, Chrome crashes when it tries
to browse for files. Building with `nix-env -iA emacs.glinux` fixes this and
other problems.

Miscellaneous other changes:
- Remove unnecessary fix-point recursion
- Drop support for unused dottime.el
- Remove unused overrideEmacs
- Remove unused withLocalConfig
- Support emacs.glinux and emacs.nixos alternative derivations
-rw-r--r--emacs/default.nix46
1 files changed, 13 insertions, 33 deletions
diff --git a/emacs/default.nix b/emacs/default.nix
index aa0fa9017d08..5ee63f7c9e3f 100644
--- a/emacs/default.nix
+++ b/emacs/default.nix
@@ -1,7 +1,6 @@
-{ pkgs, depot, ... }:
+{ pkgs, ... }:
 
 let
-  utils = import <briefcase/utils>;
   # NOTE: I'm trying to keep the list of dependencies herein constrained to a
   # list of generic dependencies (i.e. not project or language specific). For
   # language-specific tooling, I'm intending to use shell.nix alongside lorri
@@ -16,7 +15,9 @@ let
     scrot
     clipmenu
   ]);
+
   emacsWithPackages = (pkgs.emacsPackagesNgGen pkgs.emacs26).emacsWithPackages;
+
   wpcarrosEmacs = emacsWithPackages (epkgs:
     (with epkgs.elpaPackages; [
       exwm
@@ -108,38 +109,9 @@ let
       flycheck
       ivy
       magit
-    ]) ++
-
-    (with depot.tools.emacs-pkgs; [
-      dottime
     ]));
 
-# TODO: Do I need `pkgs.lib.fix`?
-in pkgs.lib.fix(self: l: f: pkgs.writeShellScriptBin "wpcarros-emacs" ''
-   # TODO: Is this the best way to handle environment variables using Nix?
-   export BRIEFCASE=$HOME/briefcase
-   export DEPOT=$HOME/depot
-
-   export PATH="${emacsBinPath}:$PATH"
-   exec ${wpcarrosEmacs}/bin/emacs \
-     --debug-init \
-     --no-site-file \
-     --no-site-lisp \
-     --directory ${ ./.emacs.d/vendor } \
-     --directory ${ ./.emacs.d/wpc } \
-     --load ${ ./.emacs.d/wpc/wpc-package.el } \
-     --load ${ ./.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 an Emacs binary outside of /nix/store. On gLinux,
-  # this will ensure that X and GL linkage behaves as expected.
-  withLocalEmacs = emacsBin: pkgs.writeShellScriptBin "wpcarros-emacs" ''
+  withEmacsPath = emacsBin: pkgs.writeShellScriptBin "wpcarros-emacs" ''
     # TODO: Is this the best way to handle environment variables using Nix?
     export BRIEFCASE=$HOME/briefcase
     export DEPOT=$HOME/depot
@@ -156,4 +128,12 @@ in pkgs.lib.fix(self: l: f: pkgs.writeShellScriptBin "wpcarros-emacs" ''
      --load ${ ./.emacs.d/init.el } \
       --no-init-file $@
   '';
-}) null utils.identity
+in {
+  # Use `nix-env -f '<briefcase>' emacs.glinux` to install `wpcarro-emacs` on
+  # gLinux machines. This will ensure that X and GL linkage behaves as expected.
+  glinux = withEmacsPath "/usr/bin/emacs";
+
+  # Use `nix-env -f '<briefcase>' emacs.nixos` to install `wpcarros-emacs` on
+  # NixOS machines.
+  nixos = withEmacsPath "${wpcarrosEmacs}/bin/emacs";
+}