about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorAtemu <atemu.main@gmail.com>2023-08-23 11:46:52 +0200
committerGitHub <noreply@github.com>2023-08-23 11:46:52 +0200
commit65f20da184625c5a631a4264acaf45706627cc2c (patch)
treec212ddf0f423e587c3d63635a9872628a64eb2ea /nixos
parentf8ce0ca885873103bc4b93b84c0bc91cd748e172 (diff)
parentd391373c40f5677081299ca210aa22eba5261c73 (diff)
Merge pull request #246008 from Atemu/emacs-daemon-fix-display
nixos/emacs: start emacs service with the graphical-session
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/editors/emacs.nix17
1 files changed, 16 insertions, 1 deletions
diff --git a/nixos/modules/services/editors/emacs.nix b/nixos/modules/services/editors/emacs.nix
index fe3a101597947..fad4f39ff2104 100644
--- a/nixos/modules/services/editors/emacs.nix
+++ b/nixos/modules/services/editors/emacs.nix
@@ -80,6 +80,15 @@ in
         using the EDITOR environment variable.
       '';
     };
+
+    startWithGraphical = mkOption {
+      type = types.bool;
+      default = config.services.xserver.enable;
+      defaultText = literalExpression "config.services.xserver.enable";
+      description = lib.mdDoc ''
+        Start emacs with the graphical session instead of any session. Without this, emacs clients will not be able to create frames in the graphical session.
+      '';
+    };
   };
 
   config = mkIf (cfg.enable || cfg.install) {
@@ -92,7 +101,13 @@ in
         ExecStop = "${cfg.package}/bin/emacsclient --eval (kill-emacs)";
         Restart = "always";
       };
-    } // optionalAttrs cfg.enable { wantedBy = [ "default.target" ]; };
+
+      unitConfig = optionalAttrs cfg.startWithGraphical {
+        After = "graphical-session.target";
+      };
+    } // optionalAttrs cfg.enable {
+      wantedBy = if cfg.startWithGraphical then [ "graphical-session.target" ] else [ "default.target" ];
+    };
 
     environment.systemPackages = [ cfg.package editorScript desktopApplicationFile ];