2025-05-04 02:47:36 +02:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2025-05-15 15:19:59 +02:00
|
|
|
}: with lib; let
|
2025-05-04 02:47:36 +02:00
|
|
|
emacsDefaultPackage = with pkgs; ((emacsPackagesFor emacsNativeComp).emacsWithPackages (
|
|
|
|
epkgs: [
|
|
|
|
epkgs.vterm
|
|
|
|
epkgs.mu4e
|
|
|
|
epkgs.pdf-tools
|
|
|
|
]
|
|
|
|
));
|
|
|
|
cfg = config.modules.emacs;
|
|
|
|
in {
|
|
|
|
options.modules.emacs = {
|
2025-05-15 15:19:59 +02:00
|
|
|
enable = mkEnableOption "enables Emacs";
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
2025-05-04 02:47:36 +02:00
|
|
|
default = emacsDefaultPackage;
|
|
|
|
};
|
2025-05-15 15:19:59 +02:00
|
|
|
service = mkEnableOption "enables Emacs service";
|
|
|
|
mu4eMime = mkEnableOption "Enables mu4e to handle mailto scheme";
|
|
|
|
org-protocol = mkEnableOption "Enables org-protocol";
|
2025-05-04 02:47:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
2025-05-15 15:19:59 +02:00
|
|
|
programs.emacs = mkIf cfg.enable {
|
2025-05-04 02:47:36 +02:00
|
|
|
enable = true;
|
|
|
|
inherit (cfg) package;
|
|
|
|
};
|
2025-05-15 15:19:59 +02:00
|
|
|
services.emacs = mkIf cfg.service {
|
2025-05-04 02:47:36 +02:00
|
|
|
enable = true;
|
|
|
|
inherit (cfg) package;
|
|
|
|
startWithUserSession = "graphical";
|
|
|
|
};
|
2025-05-15 15:19:59 +02:00
|
|
|
|
|
|
|
xdg.desktopEntries.mu4e = mkIf cfg.mu4eMime {
|
|
|
|
name = "mu4e";
|
|
|
|
genericName = "mu4e";
|
|
|
|
comment = "Maildir Utils for Emacs";
|
|
|
|
mimeType = ["x-scheme-handler/mailto"];
|
|
|
|
noDisplay = true;
|
|
|
|
exec = "${cfg.package}/bin/emacsclient -c -n -a ${cfg.package}/bin/emacs -e \"(browse-url-mail \\\"\\$*\\\")\"";
|
|
|
|
terminal = false;
|
|
|
|
categories = ["Network" "Email" "TextEditor" "Utility"];
|
|
|
|
};
|
|
|
|
|
|
|
|
xdg.desktopEntries.org-protocol = mkIf cfg.org-protocol {
|
|
|
|
name = "org-protocol";
|
|
|
|
exec = "${cfg.package}/bin/emacsclient -c -n -a ${cfg.package}/bin/emacs %u";
|
|
|
|
terminal = false;
|
|
|
|
noDisplay = true;
|
|
|
|
categories = ["System"];
|
|
|
|
mimeType = ["x-scheme-handler/org-protocol"];
|
|
|
|
};
|
2025-05-04 02:47:36 +02:00
|
|
|
};
|
|
|
|
}
|