2024-12-23 13:03:34 -05:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
inputs,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
|
|
|
cfg = config.custom.desktops.niri;
|
2024-12-28 13:30:52 -05:00
|
|
|
|
|
|
|
# TODO: Use let bindings for hm config everywhere
|
|
|
|
hm = config.home-manager.users.${config.custom.username};
|
2024-12-23 13:03:34 -05:00
|
|
|
in {
|
|
|
|
options.custom.desktops.niri = {
|
|
|
|
enable = mkOption {default = false;};
|
2024-12-23 14:45:36 -05:00
|
|
|
polkit = mkOption {default = false;};
|
2024-12-23 13:03:34 -05:00
|
|
|
xwayland = mkOption {default = true;};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-12-31 12:44:17 -06:00
|
|
|
custom = {
|
|
|
|
desktops = mkIf config.custom.full {
|
|
|
|
niri = {
|
|
|
|
binds.enable = true;
|
|
|
|
input.enable = true;
|
|
|
|
layout.enable = true;
|
|
|
|
misc.enable = true;
|
|
|
|
output.enable = true;
|
|
|
|
rules.enable = true;
|
|
|
|
};
|
2024-12-26 19:06:11 -05:00
|
|
|
|
2024-12-31 12:44:17 -06:00
|
|
|
gnome = {
|
|
|
|
enable = true;
|
|
|
|
minimal = true;
|
|
|
|
};
|
2024-12-26 19:06:11 -05:00
|
|
|
};
|
2024-12-31 12:44:17 -06:00
|
|
|
|
|
|
|
# Enable rootless Xwayland
|
|
|
|
services.xwayland-satellite.enable = cfg.xwayland;
|
2024-12-23 13:03:34 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
# https://github.com/YaLTeR/niri
|
|
|
|
# https://github.com/sodiboo/niri-flake
|
|
|
|
programs.niri = {
|
|
|
|
enable = true;
|
2024-12-28 13:30:52 -05:00
|
|
|
#// package = pkgs.niri; # nixpkgs
|
|
|
|
package = inputs.niri.packages.${pkgs.system}.default;
|
2024-12-23 13:03:34 -05:00
|
|
|
};
|
|
|
|
|
2024-12-28 13:30:52 -05:00
|
|
|
nixpkgs.overlays = [inputs.niri-flake.overlays.niri];
|
2024-12-23 13:03:34 -05:00
|
|
|
|
2025-01-01 11:46:16 -06:00
|
|
|
# Disable bundled KDE polkit agent by default
|
2024-12-23 13:03:34 -05:00
|
|
|
# https://github.com/sodiboo/niri-flake?tab=readme-ov-file#additional-notes
|
2024-12-23 14:45:36 -05:00
|
|
|
systemd.user.services.niri-flake-polkit.enable = cfg.polkit;
|
2024-12-23 13:03:34 -05:00
|
|
|
|
2024-12-31 12:44:17 -06:00
|
|
|
home-manager.sharedModules = [
|
|
|
|
{
|
|
|
|
programs.niri = {
|
|
|
|
package = config.programs.niri.package;
|
2024-12-23 13:03:34 -05:00
|
|
|
|
2024-12-31 12:44:17 -06:00
|
|
|
# https://github.com/YaLTeR/niri/wiki/Configuration:-Overview
|
|
|
|
# HACK: Prepend validated kdl config not currently implemented in settings module for e.g. custom build
|
|
|
|
# https://github.com/sodiboo/niri-flake/blob/main/settings.nix
|
2025-01-01 12:45:00 -06:00
|
|
|
config = let
|
|
|
|
# BUG: Fixed width may not take borders into account
|
|
|
|
# https://github.com/YaLTeR/niri/issues/269
|
|
|
|
pip = with config.custom; rec {
|
|
|
|
x = gap;
|
|
|
|
y = gap;
|
2025-01-02 12:02:11 -06:00
|
|
|
w = builtins.floor (width * 0.3 - gap); # 30%
|
|
|
|
h = builtins.floor (w * 9 / 16); # 16:9
|
2025-01-01 12:45:00 -06:00
|
|
|
};
|
|
|
|
in
|
|
|
|
with inputs.niri-flake.lib;
|
|
|
|
(internal.settings-module {config = hm;}).options.programs.niri.config.default
|
|
|
|
# https://github.com/sodiboo/niri-flake/blob/main/default-config.kdl.nix
|
|
|
|
++ (with kdl; [
|
|
|
|
# TODO: Migrate to window-rules when released
|
|
|
|
# https://github.com/YaLTeR/niri/pull/871
|
|
|
|
(plain "window-rule" [
|
|
|
|
(leaf "match" {is-floating = true;})
|
|
|
|
(plain "border" [(flag "off")])
|
2025-01-02 12:02:11 -06:00
|
|
|
(plain "focus-ring" [(flag "off")])
|
2025-01-01 12:45:00 -06:00
|
|
|
])
|
|
|
|
|
|
|
|
(plain "window-rule" [
|
|
|
|
(leaf "match" {title = "^Picture.in.[Pp]icture$";})
|
|
|
|
|
|
|
|
(leaf "default-floating-position" {
|
|
|
|
x = pip.x;
|
|
|
|
y = pip.y;
|
|
|
|
relative-to = "top-right";
|
|
|
|
})
|
|
|
|
|
|
|
|
(plain "default-column-width" [(leaf "fixed" (pip.w))])
|
|
|
|
(plain "default-window-height" [(leaf "fixed" (pip.h))])
|
|
|
|
(leaf "open-floating" true)
|
|
|
|
(leaf "open-focused" false)
|
|
|
|
])
|
|
|
|
]);
|
2024-12-28 13:30:52 -05:00
|
|
|
|
2024-12-31 12:44:17 -06:00
|
|
|
# https://github.com/YaLTeR/niri/wiki/Configuration:-Debug-Options
|
|
|
|
# https://github.com/sodiboo/niri-flake/blob/main/docs.md#programsnirisettingsdebug
|
|
|
|
settings.debug = {
|
|
|
|
#// disable-direct-scanout = [];
|
2025-01-02 12:01:56 -06:00
|
|
|
|
|
|
|
# BUG: Crash when multiple outputs from the same monitor are enabled
|
|
|
|
# https://github.com/YaLTeR/niri/issues/734
|
|
|
|
disable-monitor-names = [];
|
2024-12-31 12:44:17 -06:00
|
|
|
};
|
2024-12-30 13:38:52 -06:00
|
|
|
};
|
2024-12-31 12:44:17 -06:00
|
|
|
}
|
|
|
|
];
|
2024-12-23 13:03:34 -05:00
|
|
|
};
|
|
|
|
}
|