niri
警告:顯示標題「niri」覆蓋了之前的顯示標題「Niri」。
安裝
只需啟用 programs.niri:
programs.niri.enable = true;
niri-flake。
配置
niri 的配置路徑為 $XDG_CONFIG_HOME/niri/config.kdl。因此,可以使用 Home Manager 進行配置:
xdg.configFile."niri/config.kdl".source = ./config.kdl;
如果您希望在構建過程中對配置進行驗證,可以使用 pkgs.runCommand,用法如下:
xdg.configFile."niri/config.kdl".source =
pkgs.runCommand "niri-config-checked"
{
nativeBuildInputs = [ pkgs.niri ];
}
''
niri validate --config ${./config.kdl}
cp ${./config.kdl} $out
'';
有關 niri 的配置選項,請參閱 此 wiki。
Greetd
您可以使用 greeted 配置啟動 niri:
programs.niri.enable = true;
services.greetd = {
enable = true;
settings = {
default_session = {
command = "${config.programs.niri.package}/bin/niri-session";
user = "myuser";
};
};
};
# NixOS otherwise injects a stripped PATH via Environment= on the niri.service
# unit which shadows the imported user-manager PATH. Disabling the default
# lets niri inherit the full PATH set up by niri-session.
systemd.user.services.niri.enableDefaultPath = false;
額外設置
如示例 systemd 設置 (niri wiki)中所述,您可能需要設置一些額外的服務,包括以下的 Swayidle、Swaylock、Waybar、Polkit 和 Secret Service,以補充常規窗口管理器的功能。其中一些設置也是啟用默認配置文件所有功能所必需的。
security.polkit.enable = true; # polkit
services.gnome.gnome-keyring.enable = true; # secret service
security.pam.services.swaylock = {};
programs.waybar.enable = true; # top bar
environment.systemPackages = with pkgs; [ alacritty fuzzel swaylock mako swayidle ];
或者使用 Home Manager:
programs.alacritty.enable = true; # Super+T in the default setting (terminal)
programs.fuzzel.enable = true; # Super+D in the default setting (app launcher)
programs.swaylock.enable = true; # Super+Alt+L in the default setting (screen locker)
programs.waybar.enable = true; # launch on startup in the default setting (bar)
services.mako.enable = true; # notification daemon
services.swayidle.enable = true; # idle management daemon
services.polkit-gnome.enable = true; # polkit
home.packages = with pkgs; [
swaybg # wallpaper
];
故障排除
IME 在 Electron 應用中無法正常工作
有一種通用的解決方法,即按照Wayland#Electron_and_Chromium中的說明設置NIXOS_OZONE_WL:
environment.sessionVariables.NIXOS_OZONE_WL = "1";
然而,由於 niri 不支持 text-input-v1,有時需要通過手動添加 --wayland-text-input-version=3 標誌來啟用 text-input-v3,IME 才能正常工作:
$ slack --wayland-text-input-version=3
wrapProgram 可用於自動添加該標誌:
environment.systemPackages = [
(pkgs.symlinkJoin {
pname = pkgs.vscode.pname;
paths = [ pkgs.vscode ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = "wrapProgram $out/bin/code --add-flags --wayland-text-input-version=3";
};)
];
XWayland 應用無法正常工作
Niri 有一個可選依賴,強烈建議安裝(您可閱讀 這篇文章 以了解更多相關信息)。
environment.systemPackages = with pkgs; [
xwayland-satellite # xwayland support
];
或者使用 Home Manager
home.packages = with pkgs; [
xwayland-satellite # xwayland support
];
After you installed xwayland-satellite niri will integrate it out of the box and all of your XWayland apps will function properly.
文件選擇器無法正常工作
If you are using xdg-desktop-portal-gnome, it will attempt to use Nautilus as the file picker, which will fail if Nautilus is not installed.
To work around this problem, you can force usage of the gtk or kde portals for file picker instead:
xdg.portal.config.niri = {
"org.freedesktop.impl.portal.FileChooser" = [ "gtk" ]; # or "kde"
};
Waybar 啟動兩次
When using a configuration option like programs.waybar.enable, waybar may launch twice on Niri. This is because the default Niri config file launches waybar on launch. Remove the spawn-at-startup "waybar" from the config file, or add waybar to your systems packages without using the home-manager option.