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.
62 lines
1.9 KiB
Nix
62 lines
1.9 KiB
Nix
{ config, lib, pkgs, inputs, ... }@args:
|
|
|
|
# NOTE: Remember to wrap `programs.emacs.finalPackage` rather than pass a
|
|
# wrapped package to `programs.emacs.package`, lest some unexpected behaviour
|
|
# occur when home-manager calls emacs during the build process.
|
|
|
|
let
|
|
emacsPackage = pkgs.emacs30-pgtk;
|
|
emacsConfigDir = "/persist/dots/users/crumb/programs/emacs";
|
|
|
|
emacs-overlay =
|
|
import (builtins.fetchTarball {
|
|
url =
|
|
"https://github.com/nix-community/emacs-overlay/archive/master.tar.gz";
|
|
sha256 = "sha256:02aln37ch9isz8h7dlm9v6jkl60g923z0dij0rjsxq7xi61fas2j";
|
|
});
|
|
|
|
# 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;
|
|
# 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 {
|
|
system = args.system;
|
|
overlays = [ emacs-overlay ];
|
|
};
|
|
|
|
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;
|
|
# Generate a desktop entry for emacsclient.
|
|
client.enable = true;
|
|
};
|
|
}
|