{ pkgs , config , lib , ... }: with lib; let cfg = config.eboskma.programs.emacs; emacsWithPackages = pkgs.emacsWithPackagesFromUsePackage { # config = ./config.org; config = let tangledOrgConfig = pkgs.runCommand "tangled-emacs-config" { } '' cp ${./config.org} ./config.org ${cfg.package}/bin/emacs --batch -Q ./config.org -f org-babel-tangle cp init.el $out ''; in builtins.readFile tangledOrgConfig; defaultInitFile = true; package = cfg.package; alwaysEnsure = true; alwaysTangle = true; extraEmacsPackages = epkgs: [ epkgs.emacsql epkgs.emacsql-sqlite ]; }; orgProtocolDesktop = pkgs.makeDesktopItem { name = "org-protocol"; desktopName = "Emacs Org Protocol Handler"; icon = "emacs"; categories = [ "Development" "TextEditor" ]; keywords = [ "org-protocol" ]; type = "Application"; # exec = "${cfg.package}/bin/emacsclient -- %u"; exec = "${emacsWithPackages}/bin/emacsclient -- %u"; terminal = false; mimeTypes = [ "x-scheme-handler/org-protocol" ]; startupWMClass = "Emacs"; }; in { options.eboskma.programs.emacs = { enable = mkEnableOption "activate emacs"; package = mkOption { description = "The emacs package to install"; type = types.package; default = pkgs.emacs; }; daemon = mkOption { description = "Whether to enable emacs daemon"; type = types.bool; default = true; example = false; }; }; config = mkIf cfg.enable { programs.emacs = { enable = true; # package = cfg.package; package = emacsWithPackages; }; services.emacs = mkIf cfg.daemon { enable = true; # package = cfg.package; package = emacsWithPackages; client.enable = true; socketActivation.enable = true; }; home.packages = with pkgs; [ (texlive.combine { inherit (texlive) scheme-small wrapfig ulem capt-of; }) orgProtocolDesktop nodePackages.bash-language-server aspell nil python3 lldb ] ++ (with aspellDicts; [ en en-computers en-science fy nl ]); }; }