1

Modules/Niri: Init niri module

This commit is contained in:
2025-11-13 15:13:54 +01:00
parent 67e4951f7d
commit 28d0196a25
9 changed files with 1752 additions and 765 deletions

View File

@ -18,6 +18,7 @@
./lazygit
./mpd
./neovim
./niri
./nnn
./paths
./qutebrowser
@ -31,6 +32,10 @@
inputs.nix-flatpak.homeManagerModules.nix-flatpak
inputs.nixvim.homeModules.nixvim
inputs.textfox.homeManagerModules.default
# inputs.niri.homeModules.niri # Imported by system module
inputs.noctalia.homeModules.default
# inputs.dankMaterialShell.homeModules.dankMaterialShell.default
# inputs.dankMaterialShell.homeModules.dankMaterialShell.niri
# NOTE: Do NOT use this, use the system module (the HM module has to rely on fuse)
# inputs.impermanence.homeManagerModules.impermanence

View File

@ -0,0 +1,509 @@
{
config,
nixosConfig,
lib,
mylib,
pkgs,
...
}: let
inherit (config.modules) niri color;
in {
options.modules.niri = import ./options.nix {inherit lib mylib;};
config = lib.mkIf niri.enable {
assertions = [
{
assertion = nixosConfig.programs.niri.enable;
message = "Can't enable Niri module with Niri disabled!";
}
];
home = {
packages = with pkgs; [
xwayland-satellite
ncpamixer # Audio control
nautilus # Fallback file chooser used by xdg-desktop-portal-gnome
# In case we fallback to the default config
alacritty
fuzzel
];
};
programs = {
noctalia-shell = import ./noctalia.nix {inherit color;};
niri = {
# enable = true; # Enabled in system module
settings = {
input = {
focus-follows-mouse = {
enable = true;
max-scroll-amount = "0%"; # Skip partial windows that would scroll the viewport on focus
};
keyboard = {
xkb = {
layout = "us";
variant = "altgr-intl";
options = "nodeadkeys";
};
};
touchpad = {
click-method = "clickfinger";
tap = true;
drag = true;
dwt = true;
natural-scroll = true;
scroll-method = "two-finger";
};
};
hotkey-overlay = {
hide-not-bound = true;
skip-at-startup = true;
};
prefer-no-csd = true; # Disable client-side decorations (e.g. window titlebars)
spawn-at-startup = [
{argv = ["noctalia-shell"];}
{argv = ["kitty" "--hold" "fastfetch"];}
{argv = ["zeal"];}
{argv = ["nextcloud --background"];}
{argv = ["protonvpn-app"];}
{argv = ["keepassxc"];}
{argv = ["fcitx5"];}
# TODO: On certain workspaces
# {argv = ["ferdium"];}
# {argv = ["kitty --title=Btop btop"];}
# {argv = ["kitty --title=Rmpc rmpc"];}
];
workspaces = {
"1" = {open-on-output = "DP-1";};
"2" = {open-on-output = "DP-1";};
"3" = {open-on-output = "DP-1";};
"4" = {open-on-output = "DP-1";};
"5" = {open-on-output = "DP-1";};
"6" = {open-on-output = "DP-1";};
"7" = {open-on-output = "DP-1";};
"8" = {open-on-output = "DP-1";};
"9" = {open-on-output = "DP-1";};
"10" = {open-on-output = "DP-2";};
};
outputs = {
"DP-1" = {
focus-at-startup = true;
mode = {
width = 3440;
height = 1440;
refresh = 165.0;
};
position = {
x = 1920;
y = 0;
};
};
"DP-2" = {
focus-at-startup = false;
mode = {
width = 1920;
height = 1080;
refresh = 60.0;
};
position = {
x = 0;
y = 0;
};
};
};
cursor = {
hide-when-typing = true;
theme = "Bibata-Modern-Classic";
size = 24;
};
layout = {
# This border is drawn INSIDE the window
border = {
enable = true;
width = 2;
active = {color = color.hex.accent;};
inactive = {color = color.hex.base;};
};
# This border is drawn OUTSIDE of the focused window
focus-ring = {
enable = false;
};
# Hint where a dragged window will be inserted
insert-hint = {
enable = true;
display = {color = color.hex.accentDim;};
};
always-center-single-column = false;
# Gaps between windows
gaps = 8;
# Gaps at screen borders
struts = {
# left = 8;
# right = 8;
top = 4; # Somehow the bar eclusivity doesn't work as expected
bottom = 2;
};
};
gestures = {
hot-corners = {enable = false;};
};
window-rules = [
# Rules for all windows
{
clip-to-geometry = true;
geometry-corner-radius = {
bottom-left = 8.0;
bottom-right = 8.0;
top-left = 8.0;
top-right = 8.0;
};
}
# Assign to workspaces
{
matches = [{app-id = "Zotero";}];
open-on-workspace = "2";
}
{
matches = [{app-id = "neovide";}];
open-on-workspace = "2";
}
{
matches = [{app-id = "code-url-handler";}];
open-on-workspace = "2";
}
{
matches = [{app-id = "obsidian";}];
open-on-workspace = "3";
}
{
matches = [{app-id = "firefox";}];
open-on-workspace = "4";
}
{
matches = [{app-id = "Google-chrome";}];
open-on-workspace = "4";
}
{
matches = [{app-id = "chromium-browser";}];
open-on-workspace = "4";
}
{
matches = [{app-id = "org.qutebrowser.qutebrowser";}];
open-on-workspace = "4";
}
{
matches = [{app-id = "steam";}];
open-on-workspace = "5";
}
{
matches = [{app-id = "steam_app_(.+)";}];
open-on-workspace = "6";
}
{
matches = [{app-id = "signal";}];
open-on-workspace = "7";
}
{
matches = [{app-id = "discord";}];
open-on-workspace = "9";
}
];
layer-rules = [
{
# Set the overview wallpaper on the backdrop.
matches = [{namespace = "^noctalia-overview*";}];
place-within-backdrop = true;
}
];
debug = {
# Allows notification actions and window activation from Noctalia.
honor-xdg-activation-with-invalid-serial = [];
};
# TODO: Only start hypr... stuff with hyprland, not systemd (hypridle, hyprpaper currently)
# TODO: Move values to config option and set in home/christoph/niri.nix
binds = with config.lib.niri.actions; {
# Applications
"Mod+T" = {
action = spawn "kitty";
hotkey-overlay = {title = "Spawn Kitty.";};
};
"Mod+E" = {
action = spawn "kitty" "--title=Yazi" "yazi";
hotkey-overlay = {title = "Spawn Yazi.";};
};
"Mod+B" = {
action = spawn "kitty" "--title=Btop" "btop";
hotkey-overlay = {title = "Spawn Btop.";};
};
"Mod+R" = {
action = spawn "kitty" "--title=Rmpc" "rmpc";
hotkey-overlay = {title = "Spawn Rmpc.";};
};
"Mod+N" = {
action = spawn "neovide";
hotkey-overlay = {title = "Spawn Neovide.";};
};
"Mod+Ctrl+N" = {
action = spawn "kitty" "--title=Navi" "navi";
hotkey-overlay = {title = "Call Navi for help.";};
};
"Mod+Shift+N" = {
action = spawn "neovide" "${config.paths.dotfiles}/navi/christoph.cheat";
hotkey-overlay = {title = "Edit the Navi cheats.";};
};
"Mod+Shift+F" = {
action = spawn "neovide" "${config.paths.dotfiles}/flake.nix";
hotkey-overlay = {title = "Edit the NixFlake.";};
};
# Noctalia
"Mod+A" = {
action = spawn "noctalia-shell" "ipc" "call" "launcher" "toggle";
hotkey-overlay = {title = "Toggle the application launcher.";};
};
"Mod+Ctrl+L" = {
action = spawn "noctalia-shell" "ipc" "call" "lockScreen" "lock";
hotkey-overlay = {title = "Lock the screen.";};
};
"Mod+W" = {
action = spawn "noctalia-shell" "ipc" "call" "wallpaper" "toggle";
hotkey-overlay = {title = "Toggle the wallpaper chooser.";};
};
"Mod+Escape" = {
action = spawn "noctalia-shell" "ipc" "call" "sessionMenu" "toggle";
hotkey-overlay = {title = "Toggle the session menu.";};
};
# Screenshots
"Mod+S" = {
action.screenshot-window = {write-to-disk = true;};
hotkey-overlay = {title = "Take a screenshot of the current window.";};
};
"Mod+Shift+S" = {
action.screenshot = {show-pointer = true;};
hotkey-overlay = {title = "Take a screenshot of a region.";};
};
# Audio
"XF86AudioRaiseVolume" = {
action = spawn "wpctl" "set-volume" "-l" "1.5" "@DEFAULT_AUDIO_SINK@" "5%+";
hotkey-overlay = {hidden = true;};
};
"XF86AudioLowerVolume" = {
action = spawn "wpctl" "set-volume" "-l" "1.5" "@DEFAULT_AUDIO_SINK@" "5%-";
hotkey-overlay = {hidden = true;};
};
"XF86AudioPlay" = {
action = spawn "playerctl" "play-pause";
hotkey-overlay = {hidden = true;};
};
"XF86AudioPrev" = {
action = spawn "playerctl" "previous";
hotkey-overlay = {hidden = true;};
};
"XF86AudioNext" = {
action = spawn "playerctl" "next";
hotkey-overlay = {hidden = true;};
};
# Niri
"Mod+Shift+Slash" = {
action = show-hotkey-overlay;
hotkey-overlay = {hidden = true;};
};
# Niri windows
"Mod+Q" = {
action = close-window;
hotkey-overlay = {title = "Close the current window.";};
};
"Mod+F" = {
action = fullscreen-window;
hotkey-overlay = {title = "Toggle between fullscreen and tiled window.";};
};
"Mod+Equal" = {
action = set-column-width "+10%";
hotkey-overlay = {title = "Increase column width";};
};
"Mod+Minus" = {
action = set-column-width "-10%";
hotkey-overlay = {title = "Decrease column width";};
};
"Mod+Shift+M" = {
action = set-column-width "50%";
hotkey-overlay = {title = "Set column width to 50%";};
};
"Mod+M" = {
action = maximize-column;
hotkey-overlay = {title = "Maximize column.";};
};
"Mod+V" = {
action = toggle-window-floating;
hotkey-overlay = {title = "Toggle between floating and tiled window.";};
};
"Mod+O" = {
action = toggle-overview;
hotkey-overlay = {title = "Toggle overlay.";};
};
"Mod+H" = {
action = focus-column-or-monitor-left;
hotkey-overlay = {title = "Focus column on the left. Equivalent bindings for other directions.";};
};
"Mod+J" = {
action = focus-window-or-workspace-down;
hotkey-overlay = {hidden = true;};
};
"Mod+K" = {
action = focus-window-or-workspace-up;
hotkey-overlay = {hidden = true;};
};
"Mod+L" = {
action = focus-column-or-monitor-right;
hotkey-overlay = {hidden = true;};
};
"Mod+WheelScrollUp" = {
action = focus-column-left;
hotkey-overlay = {title = "Focus column on the left. Equivalent binding for other direction.";};
};
"Mod+WheelScrollDown" = {
action = focus-column-right;
hotkey-overlay = {hidden = true;};
};
"Mod+Shift+WheelScrollUp" = {
action = focus-workspace-up;
hotkey-overlay = {title = "Focus previous workspace. Equivalent binding for other direction.";};
};
"Mod+Shift+WheelScrollDown" = {
action = focus-workspace-down;
hotkey-overlay = {hidden = true;};
};
"Mod+Shift+H" = {
action = move-column-left;
hotkey-overlay = {title = "Move column to the left. Equivalent bindings for other directions.";};
};
"Mod+Shift+J" = {
action = move-window-down;
hotkey-overlay = {hidden = true;};
};
"Mod+Shift+K" = {
action = move-window-up;
hotkey-overlay = {hidden = true;};
};
"Mod+Shift+L" = {
action = move-column-right;
hotkey-overlay = {hidden = true;};
};
# Niri workspaces
"Mod+1" = {
action = focus-workspace 1;
hotkey-overlay = {title = "Focus workspace 1. Equivalent bindings for other workspaces.";};
};
"Mod+2" = {
action = focus-workspace 2;
hotkey-overlay = {hidden = true;};
};
"Mod+3" = {
action = focus-workspace 3;
hotkey-overlay = {hidden = true;};
};
"Mod+4" = {
action = focus-workspace 4;
hotkey-overlay = {hidden = true;};
};
"Mod+5" = {
action = focus-workspace 5;
hotkey-overlay = {hidden = true;};
};
"Mod+6" = {
action = focus-workspace 6;
hotkey-overlay = {hidden = true;};
};
"Mod+7" = {
action = focus-workspace 7;
hotkey-overlay = {hidden = true;};
};
"Mod+8" = {
action = focus-workspace 8;
hotkey-overlay = {hidden = true;};
};
"Mod+9" = {
action = focus-workspace 9;
hotkey-overlay = {hidden = true;};
};
"Mod+0" = {
action = focus-workspace 10;
hotkey-overlay = {hidden = true;};
};
"Mod+Shift+1" = {
action.move-window-to-workspace = 1;
hotkey-overlay = {title = "Move current window to workspace 1. Equivalent bindings for other workspaces.";};
};
"Mod+Shift+2" = {
action.move-window-to-workspace = 2;
hotkey-overlay = {hidden = true;};
};
"Mod+Shift+3" = {
action.move-window-to-workspace = 3;
hotkey-overlay = {hidden = true;};
};
"Mod+Shift+4" = {
action.move-window-to-workspace = 4;
hotkey-overlay = {hidden = true;};
};
"Mod+Shift+5" = {
action.move-window-to-workspace = 5;
hotkey-overlay = {hidden = true;};
};
"Mod+Shift+6" = {
action.move-window-to-workspace = 6;
hotkey-overlay = {hidden = true;};
};
"Mod+Shift+7" = {
action.move-window-to-workspace = 7;
hotkey-overlay = {hidden = true;};
};
"Mod+Shift+8" = {
action.move-window-to-workspace = 8;
hotkey-overlay = {hidden = true;};
};
"Mod+Shift+9" = {
action.move-window-to-workspace = 9;
hotkey-overlay = {hidden = true;};
};
"Mod+Shift+0" = {
action.move-window-to-workspace = 10;
hotkey-overlay = {hidden = true;};
};
};
};
};
};
};
}

View File

@ -0,0 +1,242 @@
{color}: {
enable = true;
settings = {
# configure noctalia here; defaults will
# be deep merged with these attributes.
colorSchemes.predefinedScheme = "Catppuccin";
general = {
avatarImage = ../../../config/face.jpeg;
radiusRatio = 0.2;
showScreenCorners = false;
forceBlackScreenCorners = false;
dimDesktop = true;
scaleRatio = 1;
screenRadiusRatio = 1;
animationSpeed = 1;
animationDisabled = false;
compactLockScreen = false;
lockOnSuspend = true;
enableShadows = true;
shadowDirection = "bottom_right";
shadowOffsetX = 2;
shadowOffsetY = 3;
language = "";
};
ui = {
fontDefault = color.font;
fontFixed = color.font;
tooltipsEnabled = true;
panelsAttachedToBar = true;
settingsPanelAttachTobar = true;
fontDefaultScale = 1;
fontFixedScale = 1;
settingsPanelAttachToBar = false;
};
location = {
name = "Dortmund, Germany";
monthBeforeDay = true;
weatherEnabled = true;
useFahrenheit = false;
use12hourFormat = false;
showWeekNumberInCalendar = false;
showCalendarEvents = true;
showCalendarWeather = true;
analogClockInCalendar = false;
firstDayOfWeek = -1;
};
screenRecorder = {
directory = "~/Videos/Recordings";
frameRate = 60;
audioCodec = "aac";
videoCodec = "h265";
quality = "very_high";
colorRange = "limited";
showCursor = true;
audioSource = "default_output";
videoSource = "portal";
};
wallpaper = {
enabled = true;
overviewEnabled = true;
directory = "~/NixFlake/wallpapers";
enableMultiMonitorDirectories = false;
recursiveSearch = false;
setWallpaperOnAllMonitors = true;
defaultWallpaper = ../../../wallpapers/Windows.jpg;
fillMode = "crop";
fillColor = "#000000";
randomEnabled = false;
randomIntervalSec = 300;
transitionDuration = 1500;
transitionType = "random";
transitionEdgeSmoothness = 0.05;
monitors = [];
panelPosition = "follow_bar";
};
appLauncher = {
enableClipboardHistory = true;
position = "center";
backgroundOpacity = 1;
pinnedExecs = [];
useApp2Unit = false;
sortByMostUsed = true;
terminalCommand = "kitty -e";
customLaunchPrefixEnabled = false;
customLaunchPrefix = "";
};
dock = {
enabled = false;
};
network = {
wifiEnabled = true;
bluetoothEnabled = true;
};
notifications = {
enabled = true;
monitors = [];
location = "top_right";
overlayLayer = true;
backgroundOpacity = 1;
respectExpireTimeout = false;
lowUrgencyDuration = 3;
normalUrgencyDuration = 8;
criticalUrgencyDuration = 15;
};
osd = {
enabled = true;
location = "top_right";
monitors = [];
autoHideMs = 2000;
overlayLayer = true;
};
audio = {
volumeStep = 5;
volumeOverdrive = true;
cavaFrameRate = 30;
visualizerType = "linear";
visualizerQuality = "high";
mprisBlacklist = [];
preferredPlayer = "";
};
nightLight = {
enabled = false;
forced = false;
autoSchedule = true;
nightTemp = "5000";
dayTemp = "6500";
manualSunrise = "06:30";
manualSunset = "21:30";
};
sessionMenu = {
countdownDuration = 10000;
enableCountdown = true;
position = "center";
powerOptions = [
{
action = "lock";
enabled = true;
}
{
action = "suspend";
enabled = false;
}
{
action = "reboot";
enabled = true;
}
{
action = "logout";
enabled = true;
}
{
action = "shutdown";
enabled = true;
}
];
showHeader = true;
};
bar = {
density = "default";
position = "top";
showCapsule = false;
outerCorners = false;
exclusive = true;
backgroundOpacity = 1;
monitors = [];
floating = false;
marginVertical = 0.25;
marginHorizontal = 0.25;
widgets = {
left = [
{
id = "SidePanelToggle";
useDistroLogo = true;
}
{
hideUnoccupied = false;
id = "Workspace";
labelMode = "none";
}
{
id = "ActiveWindow";
width = 250; # TODO: Doesn't work
}
];
center = [
{
id = "MediaMini";
width = 250; # TODO: Doesn't work
}
{
id = "AudioVisualizer";
width = 100; # TODO: Doesn't work
}
];
right = [
{
id = "Volume";
}
{
id = "Microphone";
}
{
id = "WiFi";
}
{
id = "Bluetooth";
}
{
id = "Tray";
drawer = false; # TODO: Doesn't work
}
{
formatHorizontal = "yyyy:MM:dd HH:mm";
formatVertical = "HH mm";
id = "Clock";
useMonospacedFont = true;
usePrimaryColor = true;
}
{
id = "NotificationHistory";
}
];
};
};
};
}

View File

@ -0,0 +1,7 @@
{
lib,
mylib,
...
}: {
enable = lib.mkEnableOption "Niri";
}