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:
parent
5056a1cf0c
commit
d1a3298de0
1 changed files with 18 additions and 12 deletions
|
@ -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;
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue