mirror of
https://github.com/willemml/dotfiles.nix.git
synced 2025-04-13 03:37:18 +00:00
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.
47 lines
1.2 KiB
Nix
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;
|
|
};
|
|
}
|