dotfiles.nix/home-manager/modules/emacs.nix
willemml a7c69788b0
Fixes TeX module for Emacs
Adds support for changing the org and tex config file path. Also makes
extra packages needed by org and tex customizable outside of the
module definition.

Additionally this makes the launchd service for Emacs on darwin use
the finalPackge output instead of package. This improves compatibility
with existing home-manager modules as well as my additions for
controlling whether or not org and tex are configured.
2023-11-08 14:54:48 -08:00

47 lines
1.2 KiB
Nix

{
pkgs,
lib,
config,
...
}: let
inherit (lib.types) path str anything either package listOf;
inherit (lib) mkIf mkEnableOption mkOption;
cfg = config.programs.emacs;
configFileOption = mkOption {
type = either path str;
default = "";
};
fileFromPathOrText = input:
if (builtins.typeOf input) == "path"
then {
source = input;
}
else {
text = input;
};
in {
options.programs.emacs = {
enableOrgTex = mkEnableOption "Enable Emacs Org and LaTeX configuration";
texPackages = mkOption {
type = listOf package;
default = [];
};
texEmacsPackages = lib.mkOption {
type = anything;
default = epkgs: [];
};
orgTexConfigFile = configFileOption;
initFile = configFileOption;
earlyInitFile = configFileOption;
};
config = {
home.packages = mkIf cfg.enableOrgTex cfg.texPackages;
programs.emacs.extraPackages = mkIf cfg.enableOrgTex cfg.texEmacsPackages;
home.file.".emacs.d/org-tex-cfg.el" = mkIf cfg.enableOrgTex (fileFromPathOrText cfg.orgTexConfigFile);
home.file.".emacs.d/early-init.el" = fileFromPathOrText cfg.earlyInitFile;
home.file.".emacs.d/init.el" = fileFromPathOrText cfg.initFile;
};
}