feat(emacs): Spell-checking

- Uses Aspell and Jinx.
This commit is contained in:
Madeleine Sydney
2025-02-17 21:36:30 -07:00
parent 12caaa6097
commit e730599357
5 changed files with 89 additions and 36 deletions

View File

@@ -33,35 +33,57 @@ let
fontPackages = [
pkgs.julia-mono
pkgs.nerd-fonts.victor-mono
# pkgs.overpass
pkgs.ibm-plex
];
emacsWrapper = pkgs.symlinkJoin {
name = "emacs-wrapper";
paths = [ emacsPackage ];
nativeBuildInputs = [ pkgs.makeWrapper ];
buildInputs = [
pkgs.git # Dependency of Straight.el.
];
postBuild = ''
# The binary called `emacs` is actually a symlink to `emacs-«version»`, so
# we needn't wrap it.
for i in $out/bin/emacs-*; do
wrapProgram "$i" \
--add-flags "--init-directory \"${emacsConfigDir}\"" \
--set EMACS_STRAIGHT_BASE_DIR "${straightBaseDir}" \
--set EMACS_CACHE_DIR "${emacsCacheDir}" \
--set EMACS_DATA_DIR "${emacsDataDir}" \
--prefix PATH : "${pkgs.git}/bin"
done
'';
};
my-aspell = pkgs.aspellWithDicts
(dicts: with dicts; [
en en-computers en-science
]);
emacsWrapper =
pkgs.symlinkJoin {
name = "emacs-wrapper";
paths = [ emacsPackage ];
nativeBuildInputs = [ pkgs.makeWrapper ];
buildInputs = [
pkgs.git # Dependency of Straight.el.
my-aspell
];
postBuild = ''
# The binary called `emacs` is actually a symlink to `emacs-«version»`, so
# we needn't wrap it.
for i in $out/bin/emacs-*; do
wrapProgram "$i" \
--add-flags "--init-directory \"${emacsConfigDir}\"" \
--set EMACS_STRAIGHT_BASE_DIR "${straightBaseDir}" \
--set EMACS_CACHE_DIR "${emacsCacheDir}" \
--set EMACS_DATA_DIR "${emacsDataDir}" \
--prefix PATH : "${pkgs.git}/bin" \
--prefix PATH : "${my-aspell}/bin" \
--set ASPELL_CONF "dict-dir ${my-aspell}/lib/aspell"
done
# HACK: Prevent collision between `emacsWrapper` and the later
# `emacsWithPackages` call.
# find $out/bin -not -regex '.*/\.?emacs[^/]*' -exec rm {} \;
'';
meta = emacsPackage.meta;
version = emacsPackage.version;
};
emacsclient-or-emacs = pkgs.writeShellScriptBin "emacsclient-or-emacs" ''
emacsclient --alternate-editor=${emacsWrapper}/bin/emacs "$@"
'';
in {
programs.emacs = {
enable = true;
package = emacsWrapper;
extraPackages = epkgs: [
epkgs.jinx
];
};
sydnix.impermanence.cache.directories =
# Impermanence expects the path to be relative to ~.
map (lib.removePrefix config.home.homeDirectory) [
@@ -89,7 +111,7 @@ in {
};
home.packages = [
emacsWrapper
# emacsWrapper
emacsclient-or-emacs
] ++ fontPackages;