This repository has been archived on 2026-09-17. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
nixos-config/home/tnix/localModules/sway.nix
pijukka fc0c2a00e1 tnix: replace Hyprland with sway
Step 1 of the home-manager/desktop simplification from docs/roadmap.md
-- lukas only needs plain workspace switching (Super+1-9, already had
that under Hyprland too), not a full compositor with animations/Lua
rules/window decorations. sway is the natural minimal replacement:
i3-compatible, single plain config, no plugin system.

- hosts/tnix/configuration.nix: programs.hyprland.enable ->
  programs.sway.enable
- home/tnix/localModules/hyprland.nix + hyprpaper.nix -> sway.nix.
  Ported: workspace 1-9 bindings (same dynamic generation as before),
  app launchers (kitty/alacritty+aerc/keepassxc/qutebrowser/btop),
  volume/brightness, drive mount/unmount, wallpaper (via sway's own
  output bg, no separate daemon needed). Screenshot binding swapped
  from grimblast (Hyprland-ecosystem tool) to plain grim+slurp+wl-copy.
  Dropped as explicitly out of scope ("brauche kein Hyprland, Workspaces
  reichen"): the clock-toggle widget and light/dark theme-toggle script
  in packages.nix, both hyprctl/hyprpaper-specific with no sway
  equivalent -- can be rebuilt later if actually wanted.
- Notifications: hyprctl notify (used here, in bat.nix's battery
  script, and in the system-level battery-monitor.nix) has no sway
  equivalent; switched all three to notify-send + a new mako service
  (the standard minimal sway-ecosystem notification daemon).

Verified: nix flake check + full local build of the tnix toplevel both
succeed (needed wayland.windowManager.sway.checkConfig = false -- the
build-time config validator can't reach the wallpaper file under
/home/builder, a documented sway/home-manager limitation, not a real
config error). Cannot go further than this: tnix has been offline for
this entire session, so no nixos-rebuild test/switch or actual visual
verification is possible yet -- do that the next time tnix is on,
before relying on this.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-31 14:54:59 +02:00

113 lines
4.1 KiB
Nix
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ pkgs, ... }:
{
# Notification daemon -- sway has no hyprctl-notify equivalent, mako is
# the standard minimal choice in the sway ecosystem (used below and by
# battery-monitor.nix via plain notify-send).
services.mako.enable = true;
wayland.windowManager.sway = {
enable = true;
wrapperFeatures.gtk = true;
# The generated config references a wallpaper under the user's home
# directory, which doesn't exist in the Nix build sandbox -- sway's
# own build-time config validation fails on that even though the
# config is fine at actual runtime. Documented, expected workaround
# (straight from the error message this hits without it).
checkConfig = false;
config = {
modifier = "Mod4";
terminal = "kitty";
output = {
"eDP-1" = {
resolution = "1920x1080@60Hz";
position = "0,0";
};
"HDMI-A-2" = {
resolution = "1920x1080@60Hz";
position = "1920,0";
};
"*" = {
bg = "/home/builder/wallpapers/white.png fill";
};
};
input = {
"type:keyboard" = {
xkb_layout = "de";
xkb_options = "ctrl:nocaps";
};
"type:touchpad" = {
natural_scroll = "disabled";
};
};
# Only the plain workspace-switching behaviour lukas actually asked
# for, plus straightforward ports of the app launchers already in
# use. Dropped versus the old hyprland.nix: the clock toggle widget
# and light/dark theme-toggle script (both hyprctl-specific,
# explicitly out of scope -- "brauche kein Hyprland, Workspaces
# reichen"), waybar/tofi autostart (was already commented out for
# waybar; tofi itself still works under sway if wanted later).
keybindings =
let
modifier = "Mod4";
in
(
{
"${modifier}+q" = "kill";
"${modifier}+Shift+e" = "exec swaymsg exit";
"${modifier}+Tab" = "focus next";
"${modifier}+p" = "exec keepassxc";
"${modifier}+a" = "exec kitty";
"${modifier}+n" = "exec kitty -e v";
"${modifier}+m" = "exec alacritty -e aerc";
"${modifier}+b" = "exec kitty -e btop";
"${modifier}+o" = ''exec qutebrowser --target window --set tabs.show never --set statusbar.show in-mode --set scrolling.bar never desk.0ff.space'';
"${modifier}+f" = "exec qutebrowser";
"Print" = ''exec grim -g "$(slurp)" - | wl-copy'';
"XF86AudioLowerVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-";
"XF86AudioRaiseVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+";
"XF86MonBrightnessDown" = "exec brightnessctl set 5%-";
"XF86MonBrightnessUp" = "exec brightnessctl set 5%+";
"${modifier}+u" = ''exec bash -c 'udiskie-umount -a && rm -f ~/juno && rm -f ~/LukasDisk && notify-send "💿 Laufwerke ausgehängt" || notify-send "⚠️ Aushängen fehlgeschlagen"' '';
"${modifier}+Shift+u" = ''exec bash -c 'udiskie-mount -a && ln -sfn /run/media/builder/juno ~/juno && ln -sfn /run/media/builder/LukasDisk ~/LukasDisk && notify-send "📁 Laufwerke eingehängt" || notify-send "⚠️ Einhängen fehlgeschlagen"' '';
}
// (
# Workspace bindings 1-9, same dynamic generation as before
builtins.listToAttrs (
builtins.genList (
i:
let
ws = builtins.toString (i + 1);
in
{
name = "${modifier}+${ws}";
value = "workspace number ${ws}";
}
) 9
)
)
// (
builtins.listToAttrs (
builtins.genList (
i:
let
ws = builtins.toString (i + 1);
in
{
name = "${modifier}+Shift+${ws}";
value = "move container to workspace number ${ws}";
}
) 9
)
)
);
};
};
}