wip: feat: Just use straight.el...

Every Nixy solution I could find or conceive had too many points spread across
these various facets:
  - Flimsy (emacsWithPackagesFromUsePackage)
  - Inelegant (builtins.exec, manual listings)
  - Inflexible (emacsWithPackagesFromUsePackage)
  - Otherwise unergonomic (everything }:D)

Straight.el is sufficiently declarative, flexible, and Nix-friendly without
blindly bowing down to the imperialist NixOS user.  Now, Convenience and
ergonomics shan't be forsaken for the dogma that is total Nixation.
This commit is contained in:
Madeleine Sydney
2025-01-05 00:56:03 -07:00
parent b23492e42b
commit 1aee1366c2
5 changed files with 83 additions and 19 deletions

View File

@@ -17,8 +17,8 @@ let
# Create a new instance of nixpkgs with emacs-overlay applied. This is a
# little unorthodox, but we do it
# 1. for the sake of organisation — For pure aesthetics and a clean codebase, I want
# everything Emacs to stay in this file;
# 1. for the sake of organisation — For pure aesthetics and a clean
# codebase, I want everything Emacs to stay in this file;
# 2. and, there's simply no need to leak emacs-overlay's packages into the
# global nixpkgs instance when nothing else is using it!
pkgs' = import inputs.nixpkgs {
@@ -26,20 +26,32 @@ let
overlays = [ emacs-overlay ];
};
my-emacs = pkgs'.emacsWithPackagesFromUsePackage {
config = ./emacs/init.el;
defaultInitFile = false;
package = emacsPackage;
alwaysEnsure = true;
};
in {
programs.emacs = {
enable = true;
package = my-emacs;
extraConfig = ''
(load (file-name-concat "${emacsConfigDir}" "init"))
straightBaseDir = "${config.xdg.dataHome}/straight";
emacsWrapper = pkgs.symlinkJoin {
name = "emacs-wrapper";
paths = [ emacsPackage ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
for i in $out/bin/emacs-*; do
wrapProgram "$i" \
--add-flags "--init-directory \"${emacsConfigDir}\""
done
'';
};
in {
sydnix.impermanence.cache.directories = [ straightBaseDir ];
home.packages = [ emacsWrapper ];
home.sessionVariables.EMACS_STRAIGHT_BASE_DIR = straightBaseDir;
# programs.emacs = {
# enable = true;
# package = emacsPackage;
# # extraConfig = ''
# # (load (file-name-concat "${emacsConfigDir}" "init"))
# # '';
# };
services.emacs = {
enable = true;

View File

@@ -0,0 +1,3 @@
;;; early-init.el -*- lexical-binding: t; -*-
(setq package-enable-at-startup nil)

View File

@@ -1,6 +1,32 @@
;; -*- lexical-binding: t; -*-
(require 'use-package-ensure)
(setq use-package-always-ensure t)
(defvar bootstrap-version)
(use-package evil)
(setq straight-base-dir
(or (getenv "EMACS_STRAIGHT_BASE_DIR")
(error "Cannot initialise straight: $EMACS_STRAIGHT_BASE_DIR is undefined!")))
(let ((bootstrap-file
(file-name-concat straight-base-dir
"repos/straight.el/bootstrap.el"))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(let* ((url "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el")
(url-buffer (url-retrieve-synchronously
url 'silent 'inhibit-cookies)))
(with-current-buffer url-buffer
(goto-char (point-max))
(eval-print-last-sexp))))
(load bootstrap-file nil 'nomessage))
(setq straight-use-package-by-default t)
(use-package evil
:init
(setq evil-want-minibuffer t)
:config
(evil-mode 1))
(use-package which-key
:config
(which-key-mode 1))