1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 03:29:45 +01:00

emacs: add darwin service

This commit is contained in:
klchen0112 2024-11-22 23:35:22 +08:00
parent 5056a1cf0c
commit d1a3298de0

View file

@ -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;
};
};
};
})
]);
}