Skip to content

Fix EWM session: show tuigreet session picker and stop emacs.service conflict#62

Draft
Copilot wants to merge 6 commits into
mainfrom
copilot/add-ewm-compositor-session
Draft

Fix EWM session: show tuigreet session picker and stop emacs.service conflict#62
Copilot wants to merge 6 commits into
mainfrom
copilot/add-ewm-compositor-session

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 3, 2026

EWM was unreachable at login because tuigreet never showed a session picker, and when EWM was launched it immediately failed due to a conflicting Emacs daemon.

Changes

tuigreet: show session selection menu

--cmd sway caused tuigreet to bypass the session picker entirely and hardcode sway as the launched command, making EWM (and any other registered wayland session) unreachable.

# before
"${pkgs.tuigreet}/bin/tuigreet --time --cmd sway --sessions ..."
# after
"${pkgs.tuigreet}/bin/tuigreet --time --sessions ..."

Disable emacs.service when EWM is enabled

When EWM starts as a Wayland session, it activates graphical-session.target which also starts the standalone emacs.service daemon. This second Emacs instance loads init.el with the EWM elisp package but outside of EWM's managed context — causing Emacs to send a stop signal back to the compositor (ewm.service exits 1: Stop requested from Emacs).

EWM manages its own Emacs lifecycle; the standalone daemon is redundant and conflicting when EWM is active.

# home/common/programs/emacs/default.nix
services.emacs.enable = !osConfig.programs.ewm.enable;

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • codeberg.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Goal

Add EWM (Emacs Wayland Manager) as an optional compositor/session that can be selected at the login screen (tuigreet) alongside the existing Sway session. Sway must remain fully intact and the default.

EWM flake info

EWM has a proper flake at https://codeberg.org/ezemtsov/ewm.git (branch master). The relevant flake outputs are:

nixosModules.default = import ./nix/service.nix;
overlays.default = final: _prev: {
  ewm = final.callPackage ./nix/default.nix { };
};

Full flake.nix for reference:

{
  description = "EWM - Emacs Wayland Manager";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  };

  outputs =
    { self, nixpkgs }:
    let
      supportedSystems = [
        "x86_64-linux"
        "aarch64-linux"
      ];
      forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
    in
    {
      packages = forAllSystems (
        system:
        let
          pkgs = nixpkgs.legacyPackages.${system};
        in
        {
          default = pkgs.callPackage ./nix/default.nix { };
        }
      );

      overlays.default = final: _prev: {
        ewm = final.callPackage ./nix/default.nix { };
      };

      nixosModules.default = import ./nix/service.nix;

      devShells = forAllSystems (
        system:
        let
          pkgs = nixpkgs.legacyPackages.${system};
        in
        {
          default = import ./shell.nix { inherit pkgs; };
        }
      );
    };
}

Required changes

1. flake.nix — Add EWM flake input and wire it up

Add a new input:

ewm.url = "git+https://codeberg.org/ezemtsov/ewm.git?ref=master";
ewm.inputs.nixpkgs.follows = "nixpkgs";

Add ewm = false; to each host config in hostConfigs (sky, rubble, chase), alongside the existing slack and discord options under programs:

programs = {
  slack = false;
  discord = false;
  ewm = false;  # <-- add this
};

In the mkNixosSystem function, add the EWM NixOS module to the modules list:

modules = [
  inputs.home-manager.nixosModules.home-manager
  inputs.ewm.nixosModules.default          # <-- add this
  ./hosts/${config.hostname}
  (import ./modules/nixos)
  ...

And wire up the enable flag similarly to slack/discord:

programs.ewm.enable = config.programs.ewm;

2. modules/nixos/programs/ewm.nix — New NixOS module (optional enable wrapper)

Create a new file modules/nixos/programs/ewm.nix following the exact same pattern as discord.nix and slack.nix:

{
  config,
  lib,
  ...
}:
with lib;
with builtins; let
  cfg = config.programs.ewm;
in {
  options.programs.ewm.enable = lib.mkEnableOption "EWM (Emacs Wayland Manager)";
  config = lib.mkIf cfg.enable {
    programs.ewm.enable = true;
  };
}

IMPORTANT: However, since programs.ewm options come from the EWM nixosModule itself (imported at the flake level), this wrapper module should NOT redefine programs.ewm.enable. Instead, the enable flag should be set directly in the mkNixosSystem block in flake.nix (where slack and discord enables are set). So actually, we do NOT need a separate modules/nixos/programs/ewm.nix — just set programs.ewm.enable directly in the flake like the other programs.

So the correct approach is: in flake.nix, in the module block where we have:

programs.slack.enable = config.programs.slack;
programs.discord.enable = config.programs.discord;

Just add:

programs.ewm.enable = config.programs.ewm;

Do NOT create modules/nixos/programs/ewm.nix — it would conflict with the options defined by EWM's own nixosModule.

3. hosts/common/core/default.nix — Update greetd to support session switching

Currently line 50 is:

command = "${pkgs.tuigreet}/bin/tuigreet --time --cmd sway";

Change it to:

command = "${pkgs.tuigreet}/bin/tuigreet --time --sessions /etc/greetd/sessions --cmd sway";

Wait — actually the EWM NixOS module (service.nix) registers a session with the display manager automatically. With tuigreet, the --sessions flag isn't strictly needed if EWM registers a .desktop file in the right place. The better approach is to use --sessions pointing to the standard wayland-sessions directory so tuigreet can discover all registered sessions:

command = "${pkgs.tuigreet}/bin/tuigreet --time --sessions ${config.services.displayManager.sessionData.desktops}/share/wayland-sessions --cmd sway";

Actually, the simplest and most standard approach: just add --sessions so tuigreet picks up desktop files from the standard session paths. Since we don't know the exact path the EWM module uses, the safest change is:

command = "${pkgs.tuigreet}/bin/tuigreet --time --cmd sway --sessions /usr/share/wayland-sessions";

But on NixOS the sessions are in the Nix store. The cleanest NixOS way is:

command = "${pkgs.tuigreet}/bin/tuigreet --time --cmd sway";

Actually, keep the greetd command as-...

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: KristianAN <80984519+KristianAN@users.noreply.github.com>
Copilot AI changed the title [WIP] Add EWM as an optional compositor session Add EWM as optional session alongside Sway in tuigreet Mar 3, 2026
Co-authored-by: KristianAN <80984519+KristianAN@users.noreply.github.com>
Copilot AI changed the title Add EWM as optional session alongside Sway in tuigreet Enable EWM for chase and fix greetd session discovery Mar 3, 2026
Co-authored-by: KristianAN <80984519+KristianAN@users.noreply.github.com>
Copilot AI changed the title Enable EWM for chase and fix greetd session discovery EWM: enable for chase, fix greetd session discovery, and use home-manager Emacs Mar 3, 2026
Co-authored-by: KristianAN <80984519+KristianAN@users.noreply.github.com>
Copilot AI changed the title EWM: enable for chase, fix greetd session discovery, and use home-manager Emacs EWM: use home-manager Emacs and fix tuigreet session selection Mar 3, 2026
Co-authored-by: KristianAN <80984519+KristianAN@users.noreply.github.com>
Copilot AI changed the title EWM: use home-manager Emacs and fix tuigreet session selection Fix EWM session: show tuigreet session picker and stop emacs.service conflict Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants