mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
treewide: reformat nixfmt-rfc-style
Reformat repository using new nixfmt-rfc-style.
This commit is contained in:
parent
5df48c4255
commit
cba2f9ce95
1051 changed files with 37028 additions and 26594 deletions
|
|
@ -1,4 +1,9 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
|
||||
|
|
@ -9,39 +14,36 @@ let
|
|||
emacsBinPath = "${cfg.package}/bin";
|
||||
emacsVersion = getVersion cfg.package;
|
||||
|
||||
clientWMClass =
|
||||
if versionAtLeast emacsVersion "28" then "Emacsd" else "Emacs";
|
||||
clientWMClass = if versionAtLeast emacsVersion "28" then "Emacsd" else "Emacs";
|
||||
|
||||
# Workaround for https://debbugs.gnu.org/47511
|
||||
needsSocketWorkaround = versionOlder emacsVersion "28"
|
||||
&& cfg.socketActivation.enable;
|
||||
needsSocketWorkaround = versionOlder emacsVersion "28" && cfg.socketActivation.enable;
|
||||
|
||||
# Adapted from upstream emacs.desktop
|
||||
clientDesktopItem = pkgs.writeTextDir "share/applications/emacsclient.desktop"
|
||||
(generators.toINI { } {
|
||||
clientDesktopItem = pkgs.writeTextDir "share/applications/emacsclient.desktop" (
|
||||
generators.toINI { } {
|
||||
"Desktop Entry" = {
|
||||
Type = "Application";
|
||||
Exec = "${emacsBinPath}/emacsclient ${
|
||||
concatStringsSep " " cfg.client.arguments
|
||||
} %F";
|
||||
Exec = "${emacsBinPath}/emacsclient ${concatStringsSep " " cfg.client.arguments} %F";
|
||||
Terminal = false;
|
||||
Name = "Emacs Client";
|
||||
Icon = "emacs";
|
||||
Comment = "Edit text";
|
||||
GenericName = "Text Editor";
|
||||
MimeType =
|
||||
"text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;";
|
||||
MimeType = "text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;";
|
||||
Categories = "Development;TextEditor;";
|
||||
Keywords = "Text;Editor;";
|
||||
StartupWMClass = clientWMClass;
|
||||
};
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
# Match the default socket path for the Emacs version so emacsclient continues
|
||||
# to work without wrapping it.
|
||||
socketDir = "%t/emacs";
|
||||
socketPath = "${socketDir}/server";
|
||||
in {
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ maintainers.tadfisher ];
|
||||
|
||||
options.services.emacs = {
|
||||
|
|
@ -60,7 +62,10 @@ in {
|
|||
extraOptions = mkOption {
|
||||
type = with types; listOf str;
|
||||
default = [ ];
|
||||
example = [ "-f" "exwm-enable" ];
|
||||
example = [
|
||||
"-f"
|
||||
"exwm-enable"
|
||||
];
|
||||
description = ''
|
||||
Extra command-line arguments to pass to {command}`emacs`.
|
||||
'';
|
||||
|
|
@ -87,8 +92,7 @@ in {
|
|||
startWithUserSession = mkOption {
|
||||
type = with types; either bool (enum [ "graphical" ]);
|
||||
default = !cfg.socketActivation.enable;
|
||||
defaultText =
|
||||
literalExpression "!config.services.emacs.socketActivation.enable";
|
||||
defaultText = literalExpression "!config.services.emacs.socketActivation.enable";
|
||||
example = "graphical";
|
||||
description = ''
|
||||
Whether to launch Emacs service with the systemd user session. If it is
|
||||
|
|
@ -112,76 +116,71 @@ in {
|
|||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf pkgs.stdenv.isLinux {
|
||||
systemd.user.services.emacs = {
|
||||
Unit = {
|
||||
Description = "Emacs text editor";
|
||||
Documentation =
|
||||
"info:emacs man:emacs(1) https://gnu.org/software/emacs/";
|
||||
systemd.user.services.emacs =
|
||||
{
|
||||
Unit =
|
||||
{
|
||||
Description = "Emacs text editor";
|
||||
Documentation = "info:emacs man:emacs(1) https://gnu.org/software/emacs/";
|
||||
|
||||
After = optional (cfg.startWithUserSession == "graphical")
|
||||
"graphical-session.target";
|
||||
PartOf = optional (cfg.startWithUserSession == "graphical")
|
||||
"graphical-session.target";
|
||||
After = optional (cfg.startWithUserSession == "graphical") "graphical-session.target";
|
||||
PartOf = optional (cfg.startWithUserSession == "graphical") "graphical-session.target";
|
||||
|
||||
# Avoid killing the Emacs session, which may be full of
|
||||
# unsaved buffers.
|
||||
X-RestartIfChanged = false;
|
||||
} // optionalAttrs needsSocketWorkaround {
|
||||
# Emacs deletes its socket when shutting down, which systemd doesn't
|
||||
# handle, resulting in a server without a socket.
|
||||
# See https://github.com/nix-community/home-manager/issues/2018
|
||||
RefuseManualStart = true;
|
||||
# Avoid killing the Emacs session, which may be full of
|
||||
# unsaved buffers.
|
||||
X-RestartIfChanged = false;
|
||||
}
|
||||
// optionalAttrs needsSocketWorkaround {
|
||||
# Emacs deletes its socket when shutting down, which systemd doesn't
|
||||
# handle, resulting in a server without a socket.
|
||||
# See https://github.com/nix-community/home-manager/issues/2018
|
||||
RefuseManualStart = true;
|
||||
};
|
||||
|
||||
Service =
|
||||
{
|
||||
Type = "notify";
|
||||
|
||||
# We wrap ExecStart in a login shell so Emacs starts with the user's
|
||||
# environment, most importantly $PATH and $NIX_PROFILES. It may be
|
||||
# worth investigating a more targeted approach for user services to
|
||||
# import the user environment.
|
||||
ExecStart = ''${pkgs.runtimeShell} -l -c "${emacsBinPath}/emacs --fg-daemon${
|
||||
# In case the user sets 'server-directory' or 'server-name' in
|
||||
# their Emacs config, we want to specify the socket path explicitly
|
||||
# so launching 'emacs.service' manually doesn't break emacsclient
|
||||
# when using socket activation.
|
||||
optionalString cfg.socketActivation.enable "=${escapeShellArg socketPath}"
|
||||
} ${escapeShellArgs cfg.extraOptions}"'';
|
||||
|
||||
# Emacs will exit with status 15 after having received SIGTERM, which
|
||||
# is the default "KillSignal" value systemd uses to stop services.
|
||||
SuccessExitStatus = 15;
|
||||
|
||||
Restart = "on-failure";
|
||||
}
|
||||
// optionalAttrs needsSocketWorkaround {
|
||||
# Use read-only directory permissions to prevent emacs from
|
||||
# deleting systemd's socket file before exiting.
|
||||
ExecStartPost = "${pkgs.coreutils}/bin/chmod --changes -w ${socketDir}";
|
||||
ExecStopPost = "${pkgs.coreutils}/bin/chmod --changes +w ${socketDir}";
|
||||
};
|
||||
}
|
||||
// optionalAttrs (cfg.startWithUserSession != false) {
|
||||
Install = {
|
||||
WantedBy = [
|
||||
(if cfg.startWithUserSession == true then "default.target" else "graphical-session.target")
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
Service = {
|
||||
Type = "notify";
|
||||
|
||||
# We wrap ExecStart in a login shell so Emacs starts with the user's
|
||||
# environment, most importantly $PATH and $NIX_PROFILES. It may be
|
||||
# worth investigating a more targeted approach for user services to
|
||||
# import the user environment.
|
||||
ExecStart = ''
|
||||
${pkgs.runtimeShell} -l -c "${emacsBinPath}/emacs --fg-daemon${
|
||||
# In case the user sets 'server-directory' or 'server-name' in
|
||||
# their Emacs config, we want to specify the socket path explicitly
|
||||
# so launching 'emacs.service' manually doesn't break emacsclient
|
||||
# when using socket activation.
|
||||
optionalString cfg.socketActivation.enable
|
||||
"=${escapeShellArg socketPath}"
|
||||
} ${escapeShellArgs cfg.extraOptions}"'';
|
||||
|
||||
# Emacs will exit with status 15 after having received SIGTERM, which
|
||||
# is the default "KillSignal" value systemd uses to stop services.
|
||||
SuccessExitStatus = 15;
|
||||
|
||||
Restart = "on-failure";
|
||||
} // optionalAttrs needsSocketWorkaround {
|
||||
# Use read-only directory permissions to prevent emacs from
|
||||
# deleting systemd's socket file before exiting.
|
||||
ExecStartPost =
|
||||
"${pkgs.coreutils}/bin/chmod --changes -w ${socketDir}";
|
||||
ExecStopPost =
|
||||
"${pkgs.coreutils}/bin/chmod --changes +w ${socketDir}";
|
||||
};
|
||||
} // optionalAttrs (cfg.startWithUserSession != false) {
|
||||
Install = {
|
||||
WantedBy = [
|
||||
(if cfg.startWithUserSession == true then
|
||||
"default.target"
|
||||
else
|
||||
"graphical-session.target")
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
home = {
|
||||
packages = optional cfg.client.enable (hiPrio clientDesktopItem);
|
||||
|
||||
sessionVariables = mkIf cfg.defaultEditor {
|
||||
EDITOR = getBin (pkgs.writeShellScript "editor" ''
|
||||
exec ${
|
||||
getBin cfg.package
|
||||
}/bin/emacsclient "''${@:---create-frame}"'');
|
||||
EDITOR = getBin (
|
||||
pkgs.writeShellScript "editor" ''exec ${getBin cfg.package}/bin/emacsclient "''${@:---create-frame}"''
|
||||
);
|
||||
};
|
||||
};
|
||||
})
|
||||
|
|
@ -190,8 +189,7 @@ in {
|
|||
systemd.user.sockets.emacs = {
|
||||
Unit = {
|
||||
Description = "Emacs text editor";
|
||||
Documentation =
|
||||
"info:emacs man:emacs(1) https://gnu.org/software/emacs/";
|
||||
Documentation = "info:emacs man:emacs(1) https://gnu.org/software/emacs/";
|
||||
};
|
||||
|
||||
Socket = {
|
||||
|
|
@ -221,8 +219,10 @@ in {
|
|||
launchd.agents.emacs = {
|
||||
enable = true;
|
||||
config = {
|
||||
ProgramArguments = [ "${cfg.package}/bin/emacs" "--fg-daemon" ]
|
||||
++ cfg.extraOptions;
|
||||
ProgramArguments = [
|
||||
"${cfg.package}/bin/emacs"
|
||||
"--fg-daemon"
|
||||
] ++ cfg.extraOptions;
|
||||
RunAtLoad = true;
|
||||
KeepAlive = {
|
||||
Crashed = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue