diff --git a/users/modules/emacs.nix b/users/modules/emacs.nix index 444d6b8..9dac276 100644 --- a/users/modules/emacs.nix +++ b/users/modules/emacs.nix @@ -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"]; + }; }; } diff --git a/users/phundrak/home.nix b/users/phundrak/home.nix index 369b767..7a7f098 100644 --- a/users/phundrak/home.nix +++ b/users/phundrak/home.nix @@ -51,6 +51,8 @@ enable = true; service = true; package = emacsPkg; + mu4eMime = true; + org-protocol = true; }; shell.starship.jjIntegration = true; bat.extras = true;