feat(emacs): add mailto and org-protocol handlers for Emacs

This commit is contained in:
Lucien Cartier-Tilet 2025-05-15 15:19:59 +02:00
parent 664883a40d
commit 7c510e5dba
Signed by: phundrak
SSH Key Fingerprint: SHA256:PKiD+T7oShFqdUOz1Yo8AIAtwFwCaNVoi0YmMobDd6E
2 changed files with 31 additions and 7 deletions

View File

@ -3,7 +3,7 @@
config,
lib,
...
}: let
}: with lib; let
emacsDefaultPackage = with pkgs; ((emacsPackagesFor emacsNativeComp).emacsWithPackages (
epkgs: [
epkgs.vterm
@ -14,23 +14,45 @@
cfg = config.modules.emacs;
in {
options.modules.emacs = {
enable = lib.mkEnableOption "enables Emacs";
package = lib.mkOption {
type = lib.types.package;
enable = mkEnableOption "enables Emacs";
package = mkOption {
type = types.package;
default = emacsDefaultPackage;
};
service = lib.mkEnableOption "enables Emacs service";
service = mkEnableOption "enables Emacs service";
mu4eMime = mkEnableOption "Enables mu4e to handle mailto scheme";
org-protocol = mkEnableOption "Enables org-protocol";
};
config = {
programs.emacs = lib.mkIf cfg.enable {
programs.emacs = mkIf cfg.enable {
enable = true;
inherit (cfg) package;
};
services.emacs = lib.mkIf cfg.service {
services.emacs = mkIf cfg.service {
enable = true;
inherit (cfg) package;
startWithUserSession = "graphical";
};
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"];
};
};
}

View File

@ -51,6 +51,8 @@
enable = true;
service = true;
package = emacsPkg;
mu4eMime = true;
org-protocol = true;
};
shell.starship.jjIntegration = true;
bat.extras = true;