Unverified Commit 65f20da1 authored by Atemu's avatar Atemu Committed by GitHub
Browse files

Merge pull request #246008 from Atemu/emacs-daemon-fix-display

nixos/emacs: start emacs service with the graphical-session
parents f8ce0ca8 d391373c
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -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 ];