diff --git a/modules/services/emacs.nix b/modules/services/emacs.nix index d319abf01..fa0db187b 100644 --- a/modules/services/emacs.nix +++ b/modules/services/emacs.nix @@ -1,9 +1,6 @@ { config, lib, pkgs, ... }: - with lib; - let - cfg = config.services.emacs; emacsCfg = config.programs.emacs; emacsBinPath = "${cfg.package}/bin"; @@ -41,7 +38,6 @@ let # to work without wrapping it. socketDir = "%t/emacs"; socketPath = "${socketDir}/server"; - in { meta.maintainers = [ maintainers.tadfisher ]; @@ -112,12 +108,7 @@ in { }; config = mkIf cfg.enable (mkMerge [ - { - assertions = [ - (lib.hm.assertions.assertPlatform "services.emacs" pkgs - lib.platforms.linux) - ]; - + (mkIf pkgs.stdenv.isLinux { systemd.user.services.emacs = { Unit = { Description = "Emacs text editor"; @@ -190,9 +181,9 @@ in { }/bin/emacsclient "''${@:---create-frame}"''); }; }; - } + }) - (mkIf cfg.socketActivation.enable { + (mkIf (cfg.socketActivation.enable && pkgs.stdenv.isLinux) { systemd.user.sockets.emacs = { Unit = { Description = "Emacs text editor"; @@ -222,5 +213,20 @@ in { }; }; }) + + (mkIf pkgs.stdenv.isDarwin { + launchd.agents.emacs = { + enable = true; + config = { + ProgramArguments = [ "${cfg.package}/bin/emacs" "--fg-daemon" ] + ++ cfg.extraOptions; + RunAtLoad = true; + KeepAlive = { + Crashed = true; + SuccessfulExit = false; + }; + }; + }; + }) ]); }