From 02ea79853ce42853d019ce689f533dc93e462862 Mon Sep 17 00:00:00 2001 From: andre4ik3 <62390580+andre4ik3@users.noreply.github.com> Date: Thu, 15 May 2025 07:27:36 +0400 Subject: [PATCH] emacs: respect `defaultEditor` on Darwin (#7063) Currently on Darwin, services.emacs.defaultEditor = true isn't respected, as the variable is only configured on Linux. This PR simply moves the variable out to a common block, so it's applied on all platforms. --- modules/services/emacs.nix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/services/emacs.nix b/modules/services/emacs.nix index ec9258d1..f319041b 100644 --- a/modules/services/emacs.nix +++ b/modules/services/emacs.nix @@ -120,6 +120,14 @@ in config = mkIf cfg.enable ( lib.mkMerge [ + { + home.sessionVariables = mkIf cfg.defaultEditor { + EDITOR = lib.getBin ( + pkgs.writeShellScript "editor" ''exec ${lib.getBin cfg.package}/bin/emacsclient "''${@:---create-frame}"'' + ); + }; + } + (mkIf pkgs.stdenv.isLinux { systemd.user.services.emacs = { @@ -179,15 +187,7 @@ in }; }; - home = { - packages = optional cfg.client.enable (lib.hiPrio clientDesktopItem); - - sessionVariables = mkIf cfg.defaultEditor { - EDITOR = lib.getBin ( - pkgs.writeShellScript "editor" ''exec ${lib.getBin cfg.package}/bin/emacsclient "''${@:---create-frame}"'' - ); - }; - }; + home.packages = optional cfg.client.enable (lib.hiPrio clientDesktopItem); }) (mkIf (cfg.socketActivation.enable && pkgs.stdenv.isLinux) {