mirror of
https://github.com/nix-community/home-manager
synced 2024-11-30 06:59:45 +01:00
emacs: add darwin service
This commit is contained in:
parent
16fe78182e
commit
ba9367b5a9
5 changed files with 65 additions and 9 deletions
|
@ -41,7 +41,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 +111,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 +184,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 +216,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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,6 +173,7 @@ in import nmtSrc {
|
||||||
./modules/xresources
|
./modules/xresources
|
||||||
] ++ lib.optionals isDarwin [
|
] ++ lib.optionals isDarwin [
|
||||||
./modules/launchd
|
./modules/launchd
|
||||||
|
./modules/services/emacs-darwin
|
||||||
./modules/services/espanso-darwin
|
./modules/services/espanso-darwin
|
||||||
./modules/services/git-sync-darwin
|
./modules/services/git-sync-darwin
|
||||||
./modules/services/imapnotify-darwin
|
./modules/services/imapnotify-darwin
|
||||||
|
|
23
tests/modules/services/emacs-darwin/basic.nix
Normal file
23
tests/modules/services/emacs-darwin/basic.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(self: super: rec {
|
||||||
|
emacs = pkgs.writeShellScriptBin "dummy-emacs-28.0.5" "" // {
|
||||||
|
outPath = "@emacs@";
|
||||||
|
};
|
||||||
|
emacsPackagesFor = _:
|
||||||
|
lib.makeScope super.newScope (_: { emacsWithPackages = _: emacs; });
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
services.emacs = { enable = true; };
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
serviceFile=LaunchAgents/org.nix-community.home.emacs.plist
|
||||||
|
|
||||||
|
assertFileExists "$serviceFile"
|
||||||
|
|
||||||
|
assertFileContent "$serviceFile" ${./expected-agent.plist}
|
||||||
|
'';
|
||||||
|
}
|
1
tests/modules/services/emacs-darwin/default.nix
Normal file
1
tests/modules/services/emacs-darwin/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ emacs-service-basic = ./basic.nix; }
|
22
tests/modules/services/emacs-darwin/expected-agent.plist
Normal file
22
tests/modules/services/emacs-darwin/expected-agent.plist
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>KeepAlive</key>
|
||||||
|
<dict>
|
||||||
|
<key>Crashed</key>
|
||||||
|
<true/>
|
||||||
|
<key>SuccessfulExit</key>
|
||||||
|
<false/>
|
||||||
|
</dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>org.nix-community.home.emacs</string>
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>@emacs@/bin/emacs</string>
|
||||||
|
<string>--fg-daemon</string>
|
||||||
|
</array>
|
||||||
|
<key>RunAtLoad</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Loading…
Reference in a new issue