about summary refs log tree commit diff
path: root/users/wpcarro/emacs/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'users/wpcarro/emacs/default.nix')
-rw-r--r--users/wpcarro/emacs/default.nix216
1 files changed, 143 insertions, 73 deletions
diff --git a/users/wpcarro/emacs/default.nix b/users/wpcarro/emacs/default.nix
index 0f14197375..0b3c5a6e73 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:
+#   $ nix-build -A users.wpcarro.emacs.osx -o /Applications/BillsEmacs.app
 { depot, pkgs, lib, ... }:
 
 # TODO(wpcarro): See if it's possible to expose emacsclient on PATH, so that I
@@ -14,7 +20,6 @@ let
     # Rust dependencies
     (with pkgs; [
       cargo
-      rls
       rust-analyzer
       rustc
       rustfmt
@@ -23,10 +28,14 @@ let
     (with pkgs; [
       ispell
       nix
-      pass
-      scrot
+      rust-analyzer
+      rustc
+      rustfmt
       xorg.xset
-    ])
+    ] ++
+    (if pkgs.stdenv.isLinux then [
+      scrot
+    ] else [ ]))
   );
 
   emacsWithPackages = (emacsPackagesFor emacs28).emacsWithPackages;
@@ -34,13 +43,18 @@ let
   wpcarrosEmacs = emacsWithPackages (epkgs:
     (with wpcarro.emacs.pkgs; [
       al
+      bookmark
       cycle
       list
+      macros
       maybe
+      passage
       set
       string
       struct
       symbol
+      theme
+      tuple
       vterm-mgt
       zle
     ]) ++
@@ -54,94 +68,88 @@ let
     ]) ++
 
     (with epkgs.melpaPackages; [
+      alert
+      all-the-icons
+      all-the-icons-ivy
       avy
-      org-bullets
-      sly
-      notmuch
-      elm-mode
-      ts
-      vterm
       base16-theme
-      password-store
+      cider
+      clojure-mode
+      company
+      counsel
+      counsel-projectile
       csharp-mode
+      dap-mode
+      dash
+      deadgrep
+      deferred
+      diminish
+      direnv
       dockerfile-mode
+      # TODO(wpcarro): broken since channel bump cl/10204
+      # doom-themes
+      elisp-slime-nav
+      elixir-mode
+      elm-mode
+      emojify
+      engine-mode
       evil
       evil-collection
       evil-commentary
       evil-surround
-      key-chord
-      # TODO(wpcarro): Assess whether or not I need this with Nix.
-      add-node-modules-path
-      web-mode
-      rjsx-mode
-      tide
-      prettier-js
+      f
+      fish-mode
       flycheck
-      diminish
-      doom-themes
-      telephone-line
-      which-key
-      all-the-icons
-      all-the-icons-ivy
+      flymake-shellcheck
+      general
+      go-mode
+      haskell-mode
+      helpful
       ivy
       ivy-clipmenu
-      ivy-pass
       ivy-prescient
-      restclient
-      package-lint
-      parsec
+      key-chord
+      lispyville
+      lsp-ui
+      magit
       magit-popup
-      direnv
-      alert
+      markdown-mode
       nix-mode
-      rust-mode
-      rainbow-delimiters
-      racket-mode
-      lispyville
-      elisp-slime-nav
+      notmuch
+      org-bullets
+      package-lint
+      paradox
+      parsec
+      pcre2el
+      prettier-js
+      projectile
       py-yapf
+      racket-mode
+      rainbow-delimiters
       reason-mode
-      terraform-mode
-      elixir-mode
-      go-mode
-      company
-      markdown-mode
       refine
-      deferred
-      magit
       request
-      pcre2el
-      helpful
-      # TODO(wpcarro): Determine if Nix solves this problem.
-      exec-path-from-shell
-      yasnippet
-      projectile
-      deadgrep
-      counsel
-      counsel-projectile
-      # TODO(wpcarro): Learn what this is.
-      engine-mode
-      eglot
-      dap-mode
-      lsp-ui
+      restclient
+      rjsx-mode
+      rust-mode
+      sly
       suggest
-      paradox
-      flymake-shellcheck
-      fish-mode
+      telephone-line
+      terraform-mode
+      tide
+      ts
       tuareg
-      haskell-mode
       use-package
-      general
-      clojure-mode
-      cider
-      f
-      dash
-      company
-      counsel
-      flycheck
-      emojify
+      vterm
+      web-mode
+      which-key
       yaml-mode
-    ]));
+      yasnippet
+    ]) ++
+
+    [
+      epkgs.eglot # from elpa devel
+    ]);
 
   loadPath = concatStringsSep ":" [
     ./.emacs.d/wpc
@@ -168,15 +176,76 @@ let
         ${concatStringsSep "\n  " (map (el: "--load ${el} \\") load)}
         "$@"
     '';
+
+  # 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";
+  });
 in
 {
-  inherit withEmacsPath;
-
+  # TODO(wpcarro): Support this with base.overrideAttrs or something similar.
   nixos = { load ? [ ] }: withEmacsPath {
     inherit load;
     emacsBin = "${wpcarrosEmacs}/bin/emacs";
   };
 
+  # 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" ];
+  };
+
   # 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
@@ -193,5 +262,6 @@ in
     touch $out
   '';
 
-  meta.ci.targets = [ "check" ];
+  # TODO(wpcarro): commented out because of doom-themes breakage; cl/10204
+  # meta.ci.targets = [ "check" ];
 }