Files
nixfiles/lyrathorpe/swaywm.nix
T
Emma Thorpe eb1704764f fix(sway): use the us(dvorak) variant, not a "dvorak" layout
Dvorak is a variant of the "us" XKB layout, not a layout of its own:
there is no symbols/dvorak file, so "dvorak" fails to compile.

In the greetd/cage greeter the keymap comes solely from XKB_DEFAULT_*, so
the failure left the greeter with no keymap and therefore no keyboard
input at all (mouse unaffected). Split it into
XKB_DEFAULT_LAYOUT=us + XKB_DEFAULT_VARIANT=dvorak.

The same mistake in the Sway session (home/sway.nix) was masked: the
default us keymap compiled and the failing override was silently dropped,
so the session ran QWERTY despite the dvorak setting. Use xkb_variant
there too so it is actually Dvorak.

console.keyMap = "dvorak" (workstation.nix) is unaffected -- that is a
kbd console map, a separate subsystem where "dvorak" is valid.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 18:31:47 +01:00

81 lines
2.6 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.features.swayDesktop;
in
{
options = {
features.swayDesktop.enable = lib.mkEnableOption "Enable Sway Desktop";
};
config = lib.mkIf cfg.enable {
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
extraSessionCommands = ''
# QT
export QT_QPA_PLATFORM="wayland;xcb"
export QT_QPA_PLATFORMTHEME=qt5ct
# SDL
export SDL_VIDEODRIVER=wayland
# Java
export _JAVA_AWT_WM_NONREPARENTING=1
# Misc
export CLUTTER_BACKEND=wayland
export WINIT_UNIX_BACKEND=wayland
export MOZ_ENABLE_WAYLAND=1
'';
# Core Wayland utilities. The lock screen, idle daemon, status bar and
# notification daemon are configured per-user in home/sway.nix.
extraPackages = with pkgs; [
brightnessctl
foot
grim
sway-launcher-desktop
pavucontrol
];
};
fonts.packages = with pkgs; [
noto-fonts
noto-fonts-color-emoji
font-awesome
];
# Wayland login screen (replaces console/getty login on every Sway host).
# greetd runs ReGreet inside the cage kiosk compositor; the Sway session is
# offered automatically because programs.sway registers itself via
# services.displayManager.sessionPackages. Hosts that turn off
# features.swayDesktop (e.g. EDaaS) keep plain TTY login.
programs.regreet.enable = true;
# cage reads the XKB_* environment at startup, so force the greeter onto the
# same Dvorak layout as the Sway session (home/sway.nix) -- otherwise the
# password field would be QWERTY. Dvorak is the "us" layout's variant, NOT a
# layout of its own: "dvorak" alone has no symbols/ file, so the keymap
# fails to compile and the greeter ends up with no keyboard at all (the
# greeter has no fallback, unlike a running Sway session). This overrides the
# greetd command regreet sets with mkDefault.
services.greetd.settings.default_session.command =
let
greeter = pkgs.writeShellScript "regreet-cage" ''
export XKB_DEFAULT_LAYOUT=us
export XKB_DEFAULT_VARIANT=dvorak
exec ${pkgs.dbus}/bin/dbus-run-session ${lib.getExe pkgs.cage} -s -- ${lib.getExe config.programs.regreet.package}
'';
in
"${greeter}";
# Desktop portals: enables screen sharing (wlroots) and native file pickers
# for Wayland apps such as Element and Firefox.
xdg.portal = {
enable = true;
wlr.enable = true;
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
config.common.default = "*";
};
};
}