Niri: Keybindings don't work and waybar is not displayed

Hello everyone,

I am currently trying to install niri and have encountered some problems. I have followed the configuration instructions in the NixOS Wiki exactly.

My configuration:
configuration.nix and home.nix correspond exactly to the specifications in the Wiki.

home-manager switch and nixos-rebuild switch run without errors.
niri can be started from the console. (niri)

This works:
niri starts and displays the desktop
Config file is created under ~/.config/niri/config.kdl
Super + Shift + E (exit niri) works

This does not work:
Super + T (start terminal) does not work
All other key bindings do not work
waybar is not displayed (although defined in standard config)

Additional information:
Alacritty is installed and works when started manually
No error messages in the console when starting niri
Does anyone have any idea what I might have overlooked? Do I need to activate additional services or set environment variables?

home.nix:

{ config, pkgs, home, ... }:

{
  home.username = home.username;
  home.homeDirectory = home.homeDirectory;

  home.stateVersion = "25.05"; 

  home.packages = [
    pkgs.nerd-fonts.fantasque-sans-mono
    pkgs.nerd-fonts.fira-code
    pkgs.nerd-fonts.jetbrains-mono
    pkgs.nerd-fonts.hack
  ];

  home.sessionVariables = {
    EDITOR = "hx";
    SHELL = "${pkgs.zsh}/bin/zsh";
  };

  programs = {
    home-manager.enable = true;

    zsh = {
      enable = true;
      syntaxHighlighting.enable = true;
      autosuggestion.enable = true;
      shellAliases = {
        ll = "ls -l";
        la = "ls -la";
        ezaa = "eza -1la";
        ezal = "eza -1l";
        ".." = "cd ..";
        "/" = "cd /";
        "~" = "cd ~";
      };
    };

    eza = {
      enable = false;
      enableZshIntegration = true;
      icons = "auto";
      colors = "always";
    };

    starship = {
      enable = true;
      enableZshIntegration = true;
    };

    fuzzel.enable = true;
    swaylock.enable = true;
    waybar.enable = true;
  };

  services = {
    mako.enable = true;
    swayidle.enable = true;
    polkit-gnome.enable = true;
  };
}

configuraton.nix

{ config, lib, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      ./../../nixos-modules
    ];

  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  boot.kernelPackages = pkgs.linuxPackages_latest;

  networking.hostName = "nixos-workstation"; # Define your hostname.
  networking.networkmanager.enable = true;  
  console = {
    keyMap = "de";
  };

  cli_tools.enable = true;
  gnupg.enable = true;
  zsh.enable = true;
  desktopApps = {
    freecad.enable = true;
    brave.enable = true;
    zed-editor.enable = true;
    inkscape.enable = true;
    obs-studio.enable = true;
    thunderbird.enable = true;
  };
  
  customUser.benhartmannsgruber.enable = true;

  niriWindowManager.enable = true;

  # Configure keymap in X11
  services= {
    xserver.xkb.layout = "de";
  };

  environment.systemPackages = with pkgs; [
    wget
    helix
    git
    pinentry-tty
  ];

  programs.gnupg.agent = {
    enable = true;
    enableSSHSupport = true;
    pinentryPackage = pkgs.pinentry-tty;
  };

  system.stateVersion = "25.05"; # Did you read the comment?
}

niri.nix

{ pkgs, lib, config, ... }: {
  options = {
    niriWindowManager.enable = lib.mkEnableOption "enables niri window manager";  
  };

  config = lib.mkIf config.niriWindowManager.enable {
    programs = {
      niri.enable = true;
    };

    environment.systemPackages = with pkgs; [
      wl-clipboard
    ];

    services = {
      gnome.gnome-keyring.enable = true;
      xserver = {
        enable = true;
        xkb.layout = "de";
        displayManager.gdm.enable = true;
        displayManager.gdm.wayland = true;
      };
    };

    security = {
      polkit.enable = true;
      pam.services.swaylock = {};
    };
  };
}

cli_tools.nix

{ pkgs, lib, config, ... }: {

  options = {
    cli_tools.enable = lib.mkEnableOption "additional cli tools";
  };

  config = lib.mkIf config.cli_tools.enable {
    environment.systemPackages = with pkgs; [
      alacritty
      eza
      fd
      git
      helix
      jujutsu
      openvpn
      procs
      ripgrep
      yazi
      zellij
    ];
  };
}

NixOS version used: 25.05.20250721.92c2e04 (Warbler)

Thanks :smiley:

Show your niri configuration, show your nix files. The chances are you don’t have dependencies installed that are referenced in your config, but no one can say for sure without seeing the files.

sry, original post is updated.

1 Like

Given you haven’t included an config.kdl, I’m going to assume it is the stock one from here (but it would be helpful to confirm that). Nothing immediately jumps out as wrong. The default config delegates keyboard layout to localectl. Does that give you the keyboard layout you have? Does niri msg action spawn -- alacritty work?

niri msg action spwan -- alacritty
Error: error connecting to the niri socket

Caused bx:
    NIRI_SOCKET is not set, are you running this with niri?

The config.kdl from the original repo does not change anything.

Since Super + Shift + E works, the layout should be correct.

You mentioned that Super+T doesn’t work, so how are you running niri msg action spawn -- alacritty. The error messages that you get are consistent with running that command outside of Niri.

1 Like

Sorry, I should have mentioned that you will need to grab at least the niri socket first. You can do that by looking at your run directory ls /run/user/$(id -u)/niri*.sock should give you the niri socket, and then you can export NIRI_SOCKET to that path. That should allow you to run niri commands outside of niri from some other rando tty, which is what I assumed you were doing?

After three hours of configuration, I have now discovered the following initial findings.

  1. I have connected a second monitor that is never switched on. Since it is connected via HDMI and my primary monitor is connected via DP, the HDMI monitor is somehow automatically adopted as the primary source.
  2. When I turn on the monitor connected to HDMI, I suddenly see the programs opening (Alacritty).
  3. A change to the configuration file does not show any changes to the display; changing the keyboard layout to DE worked. The monitor settings did not.
    See here:
/-output “DP-1” {
  mode “2560x1440@59.591”
  scale 1
  transform “normal”
  focus-at-startup
  position x=0 y=0
  background-color “#FF0000” // for debugging, but shows no change
}

/-output “HDMI-A-1” {
  mode “1920x1080@60.00”
  scale 1
  transform “normal”
  position x=2560 y=0
}

niri validate
DEBUG: niri_config: loaded config from "/home/<username>/.config/niri/config.kdl
INFO: niri: config is valid

I removed that home-manager should contain the settings for debugging, nothing changes.

Finaly I got it.
In config.kdl: Remebr to uncomment the node by removing “/-”!

Its uncommented and now working as acpeccted… That’s now a bit embarrassing. :rofl:

1 Like