1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19: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, ... }: { config, lib, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.emacs; cfg = config.services.emacs;
emacsCfg = config.programs.emacs; emacsCfg = config.programs.emacs;
emacsBinPath = "${cfg.package}/bin"; emacsBinPath = "${cfg.package}/bin";
@ -41,7 +38,6 @@ let
# to work without wrapping it. # to work without wrapping it.
socketDir = "%t/emacs"; socketDir = "%t/emacs";
socketPath = "${socketDir}/server"; socketPath = "${socketDir}/server";
in { in {
meta.maintainers = [ maintainers.tadfisher ]; meta.maintainers = [ maintainers.tadfisher ];
@ -112,12 +108,7 @@ in {
}; };
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
{ (mkIf pkgs.stdenv.isLinux {
assertions = [
(lib.hm.assertions.assertPlatform "services.emacs" pkgs
lib.platforms.linux)
];
systemd.user.services.emacs = { systemd.user.services.emacs = {
Unit = { Unit = {
Description = "Emacs text editor"; Description = "Emacs text editor";
@ -190,9 +181,9 @@ in {
}/bin/emacsclient "''${@:---create-frame}"''); }/bin/emacsclient "''${@:---create-frame}"'');
}; };
}; };
} })
(mkIf cfg.socketActivation.enable { (mkIf (cfg.socketActivation.enable && pkgs.stdenv.isLinux) {
systemd.user.sockets.emacs = { systemd.user.sockets.emacs = {
Unit = { Unit = {
Description = "Emacs text editor"; 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;
};
};
};
})
]); ]);
} }