Strange behaviour with sway in home-manager

I have recently started building up a fresh NixOS install from the minimal ISO. I installed sway per the wiki but with some changes. I removed dmenu and added waybar and wofi as shown below.

  programs.sway = {
    enable = true;
    wrapperFeatures.gtk = true; # so that gtk works properly
    extraPackages = with pkgs; [
      swaylock
      swayidle
      wl-clipboard
      mako # notification daemon
      alacritty # terminal
      wofi # launcher/menu program
      waybar # status bar
    ];
  };

My system still boots to the terminal and I run sway and everything appears fine. The MOD key is bound to my keyboards OS key. Typing MOD-Enter opens alacritty. The bar is definitely waybar. All looks good.

I then installed home-manager and modified my configuration to use my home.nix file to configure wayland and sway as shown below.

  wayland.windowManager.sway = {
    enable = true;
    wrapperFeatures.gtk = true;
  };

  home.packages = with pkgs; [
    swaylock
    swayidle
    wl-clipboard
    mako # notification daemon
    alacritty # terminal 
    wofi # launcher/menu program
    waybar # status bar
  ];

I did also have to add the following to my configuration after the switch to get sway to boot or I would get similar errors as seen in this thread (Sway from Home-Manager?).

  # Hardware support
  hardware = {
    opengl = {
      enable = true;
      driSupport = true;
    };
  };

I did also add the following to my configuration, but it shouldn’t have any bearing on sway’s performance.

boot.kernelModules = [ "kvm-intel" ];

I rebuilt the system and home-manager and ran sway from my console to launch sway. It looks the same but the behavior is way off. Note I made no modifications to the sway config. It appears that

  1. The MOD key is no longer the OS key but it is now Alt.
  2. The default terminal emulator (Alt-Enter) is not Alacritty. When I run echo $TERM in the terminal it returns rxvt-unicode-256color so I assume it is running the rxvt terminal emulator. I have no experience with this terminal. Alacritty is installed but it is not the default.
  3. The default bar is swaybar and not waybar. I checked this with ps -aux.
  4. When I run alacritty from the rxvt terminal, it does open but the kerning is all messed up. Some letters are spaced far apart and sometimes they overlap. rxvt does not have this problem.

Here is a link to my repo containing all my configuration files if that would be useful.
https://gitlab.com/djacu2/dotfiles-nixos

1 Like

Besides the options you are setting via home manager how are you setting up the sway configuration?

Sway at a system level will use the /etc/sway/config file but if you use home manager it will template a file in your home directory.

You can use sway --validate --verbose to see what config it is loading.

It looks like you have already begun setting more options via home manager like the mod key so perhaps you already figured this out.

2 Likes

I use a similar configuration that you can see here and mine works as expected. home-manager will replace your configuration in ~/.config/sway/config. I do apply my configuration together with the system config using the flake though…

2 Likes

Thanks for the advice all; It was configs. I assumed that the defaults would be the same between sway as a system package and it managed under home manager. The weird font behavior in alacritty threw me and I thought I messed up something. Setting the sway configs in home-manager and installing a monospace font fixed everything.

1 Like
Hosted by Flying Circus.