2017-02-19 10:20:26 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.emacs;
|
|
|
|
|
2020-11-27 02:43:13 +00:00
|
|
|
in {
|
2017-02-19 10:20:26 +00:00
|
|
|
options = {
|
|
|
|
services.emacs = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-14 21:02:32 +00:00
|
|
|
description = "Whether to enable the Emacs Daemon.";
|
2017-02-19 10:20:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = pkgs.emacs;
|
2024-04-14 21:02:32 +00:00
|
|
|
description = "This option specifies the emacs package to use.";
|
2017-02-19 10:20:26 +00:00
|
|
|
};
|
|
|
|
|
2020-11-27 02:43:13 +00:00
|
|
|
additionalPath = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
example = [ "/Users/my_user_name" ];
|
2024-04-14 21:02:32 +00:00
|
|
|
description = ''
|
2020-11-27 02:43:13 +00:00
|
|
|
This option specifies additional PATH that the emacs daemon would have.
|
|
|
|
Typically if you have binaries in your home directory that is what you would add your home path here.
|
|
|
|
One caveat is that there won't be shell variable expansion, so you can't use $HOME for example
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-07-04 19:13:32 +00:00
|
|
|
exec = mkOption {
|
2018-07-21 11:27:08 +00:00
|
|
|
type = types.str;
|
2017-07-04 19:13:32 +00:00
|
|
|
default = "emacs";
|
2024-04-14 21:02:32 +00:00
|
|
|
description = "Emacs command/binary to execute.";
|
2017-07-04 19:13:32 +00:00
|
|
|
};
|
2017-02-19 10:20:26 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
launchd.user.agents.emacs = {
|
2020-11-27 02:43:13 +00:00
|
|
|
path = cfg.additionalPath ++ [ config.environment.systemPath ];
|
|
|
|
serviceConfig.ProgramArguments =
|
|
|
|
[ "${cfg.package}/bin/${cfg.exec}" "--fg-daemon" ];
|
2017-02-19 10:20:26 +00:00
|
|
|
serviceConfig.RunAtLoad = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2017-07-04 19:13:32 +00:00
|
|
|
}
|