services.emacs: add option extraOptions

This is to allow adding command-line arguments to the Emacs daemon.
Previously only the Emacs client could be started with custom
arguments.
This commit is contained in:
schotts-fired 2021-09-29 15:07:38 +02:00 committed by Robert Helgesson
parent d5151186ac
commit 0f3dfc94ef
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
7 changed files with 16 additions and 3 deletions

View file

@ -54,6 +54,15 @@ in {
description = "The Emacs package to use."; description = "The Emacs package to use.";
}; };
extraOptions = mkOption {
type = with types; listOf str;
default = [ ];
example = [ "-f" "exwm-enable" ];
description = ''
Extra command-line arguments to pass to <command>emacs</command>.
'';
};
client = { client = {
enable = mkEnableOption "generation of Emacs client desktop file"; enable = mkEnableOption "generation of Emacs client desktop file";
arguments = mkOption { arguments = mkOption {
@ -111,7 +120,7 @@ in {
# when using socket activation. # when using socket activation.
optionalString cfg.socketActivation.enable optionalString cfg.socketActivation.enable
"=${escapeShellArg socketPath}" "=${escapeShellArg socketPath}"
}"''; } ${escapeShellArgs cfg.extraOptions}"'';
# Emacs will exit with status 15 after having received SIGTERM, which # Emacs will exit with status 15 after having received SIGTERM, which
# is the default "KillSignal" value systemd uses to stop services. # is the default "KillSignal" value systemd uses to stop services.

View file

@ -17,6 +17,7 @@ with lib;
programs.emacs.enable = true; programs.emacs.enable = true;
services.emacs.enable = true; services.emacs.enable = true;
services.emacs.client.enable = true; services.emacs.client.enable = true;
services.emacs.extraOptions = [ "-f" "exwm-enable" ];
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/systemd/user/emacs.socket assertPathNotExists home-files/.config/systemd/user/emacs.socket

View file

@ -17,6 +17,7 @@ with lib;
programs.emacs.enable = true; programs.emacs.enable = true;
services.emacs.enable = true; services.emacs.enable = true;
services.emacs.client.enable = true; services.emacs.client.enable = true;
services.emacs.extraOptions = [ "-f" "exwm-enable" ];
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/systemd/user/emacs.socket assertPathNotExists home-files/.config/systemd/user/emacs.socket

View file

@ -2,7 +2,7 @@
WantedBy=default.target WantedBy=default.target
[Service] [Service]
ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon" ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon '-f' 'exwm-enable'"
Restart=on-failure Restart=on-failure
SuccessExitStatus=15 SuccessExitStatus=15
Type=notify Type=notify

View file

@ -19,6 +19,7 @@ in {
programs.emacs.enable = true; programs.emacs.enable = true;
services.emacs.enable = true; services.emacs.enable = true;
services.emacs.client.enable = true; services.emacs.client.enable = true;
services.emacs.extraOptions = [ "-f" "exwm-enable" ];
services.emacs.socketActivation.enable = true; services.emacs.socketActivation.enable = true;
nmt.script = '' nmt.script = ''

View file

@ -19,6 +19,7 @@ in {
programs.emacs.enable = true; programs.emacs.enable = true;
services.emacs.enable = true; services.emacs.enable = true;
services.emacs.client.enable = true; services.emacs.client.enable = true;
services.emacs.extraOptions = [ "-f" "exwm-enable" ];
services.emacs.socketActivation.enable = true; services.emacs.socketActivation.enable = true;
nmt.script = '' nmt.script = ''

View file

@ -1,5 +1,5 @@
[Service] [Service]
ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon='%t/emacs/server'" ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon='%t/emacs/server' '-f' 'exwm-enable'"
ExecStartPost=@coreutils@/bin/chmod --changes -w %t/emacs ExecStartPost=@coreutils@/bin/chmod --changes -w %t/emacs
ExecStopPost=@coreutils@/bin/chmod --changes +w %t/emacs ExecStopPost=@coreutils@/bin/chmod --changes +w %t/emacs
Restart=on-failure Restart=on-failure