Switch to Niri WM

This commit is contained in:
Fern Garden 2025-08-04 18:32:17 +08:00
parent b89a6b83f0
commit c8f81f4190
15 changed files with 1196 additions and 443 deletions

View file

@ -40,50 +40,38 @@ with lib; {
# Encrypt user's home with fscrypt
security.pam.enableFscrypt = true;
# Enable the GNOME Desktop Environment.
services.xserver = {
# Enable login manager.
programs.regreet = {
enable = true;
excludePackages = [
pkgs.xterm # Don't install xterm.
];
displayManager.gdm.enable = true;
desktopManager.gnome = {
enable = true;
# Enable fractional scaling.
extraGSettingsOverridePackages = [pkgs.mutter];
extraGSettingsOverrides = ''
[org.gnome.mutter]
experimental-features=['scale-monitor-framebuffer']
'';
cageArgs = ["-m" "last"];
font = {
size = 11;
name = "Adwaita Sans";
};
};
# Theme QT applications
qt = {
# Enable window manager.
programs.niri = {
enable = true;
platformTheme = "gnome";
style = "adwaita-dark";
package = pkgs.niri-unstable;
};
# Exclude some default gnome applications.
environment.gnome.excludePackages = (
with pkgs; [
epiphany # Browser (replaced by Firefox).
gnome-connections # Remote desktop viewer.
gnome-console # Terminal (replaced by ghostTTY).
gnome-maps # Maps viewer.
gnome-music # Music player.
gnome-tour # First-boot tour.
totem # Movie player (replaced by Celluloid).
yelp # Help viewer.
]
);
# Set wallpaper.
stylix.image = ./wallpaper.jpg;
# Run electron apps under wayland.
environment.sessionVariables.NIXOS_OZONE_WL = "1";
programs.dconf.enable = true;
security.polkit.enable = true;
services.hardware.bolt.enable = true;
services.upower.enable = true;
services.libinput.enable = true;
xdg.portal = {
enable = true;
extraPortals = [
pkgs.xdg-desktop-portal-gnome
pkgs.xdg-desktop-portal-gtk
];
};
# Virtualisation.
programs.virt-manager.enable = true;
@ -103,56 +91,8 @@ with lib; {
};
};
# Install some packages.
programs = {
steam.enable = true;
firefox.enable = true;
};
environment.systemPackages = with pkgs; [
adw-gtk3
adwsteamgtk
caligula
celluloid
deploy-rs
discord
feishin
fluffychat
fusee-nano
ghostty
gimp3
glabels-qt
gnome-tweaks
gnomeExtensions.adw-gtk3-colorizer
gnomeExtensions.auto-move-windows
gnomeExtensions.caffeine
gnomeExtensions.color-picker
gnomeExtensions.rounded-window-corners-reborn
gnomeExtensions.smile-complementary-extension
jellyfin-media-player
libreoffice
nextcloud-client
ns-usbloader
obsidian
prismlauncher
protonmail-desktop
rockbox-utility
signal-desktop
smile
via
yubioath-flutter
];
fonts.packages = with pkgs; [
merriweather
iosevka
];
# Allow opening terminal applications from gnome app launcher.
xdg.terminal-exec = {
enable = true;
settings.default = ["ghostty.desktop"];
};
# Install Steam client.
programs.steam.enable = true;
# Enable configuration of keyboard.
hardware.keyboard.qmk.enable = true;
@ -173,9 +113,15 @@ with lib; {
drivers = [pkgs.brlaser pkgs.cups-dymo]; # Brother laser printer & Dymo label printer.
};
services.system-config-printer.enable = true;
# https://github.com/tailscale/tailscale/issues/4432#issuecomment-1112819111
networking.firewall.checkReversePath = false;
# Enable brightness control.
hardware.brillo.enable = true;
users.groups.video.members = ["fern"];
# Enable sound with pipewire.
services.pulseaudio.enable = false;
security.rtkit.enable = true;
@ -191,23 +137,28 @@ with lib; {
services.tlp.enable = mkForce false; # enabled by nixos-hardware
services.auto-cpufreq.enable = true;
# Home manager settings.
home-manager.users.fern = {
# Ghostty settings.
programs.ghostty = {
enable = true;
settings = {
font-family = "IosevkaCustom";
theme = "GruvboxDarkHard";
# Samba file sharing.
services.samba = {
enable = true;
openFirewall = true;
settings = {
global = {
"workgroup" = "FLOCK";
"server string" = "muskduck";
"netbios name" = "muskduck";
"security" = "user";
};
};
# virt-manager - autoconnect to qemu.
dconf.settings = {
"org/virt-manager/virt-manager/connections" = {
autoconnect = ["qemu:///system"];
uris = ["qemu:///system"];
"Music" = {
"path" = "/home/fern/Music";
"browseable" = "yes";
"read only" = "yes";
"guest ok" = "no";
};
};
};
services.samba-wsdd = {
enable = true;
openFirewall = true;
};
}

368
suites/desktop/home.nix Normal file
View file

@ -0,0 +1,368 @@
{
lib,
pkgs,
...
}:
with lib; {
imports = [../home.nix];
# Consistent theming.
qt.enable = true;
gtk.enable = true;
programs.niri = {
settings = {
# Wayland environment variables.
environment = {
CLUTTER_BACKEND = "wayland";
DISPLAY = null;
GDK_BACKEND = "wayland,x11";
MOZ_ENABLE_WAYLAND = "1";
NIXOS_OZONE_WL = "1";
QT_QPA_PLATFORM = "wayland;xcb";
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
SDL_VIDEODRIVER = "wayland";
};
# X11 support.
xwayland-satellite = {
enable = true;
path = getExe pkgs.xwayland-satellite-unstable;
};
# Don't show client-side window decorations.
prefer-no-csd = true;
# Don't show hotkeys at startup.
hotkey-overlay.skip-at-startup = true;
# Disable hot corner.
gestures.hot-corners.enable = false;
# Keyboard, mouse, trackpad, trackpoint.
input = {
touchpad.natural-scroll = false;
keyboard.repeat-rate = 60;
};
binds = {
# Spawn programs.
"Mod+Return".action.spawn = "kitty";
"Mod+Space".action.spawn = "fuzzel";
"Mod+Alt+L".action.spawn = "hyprlock";
# Media & brightness control.
"XF86AudioRaiseVolume" = {
allow-when-locked = true;
action.spawn = ["wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "5%+"];
};
"XF86AudioLowerVolume" = {
allow-when-locked = true;
action.spawn = ["wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "5%-"];
};
"XF86AudioMute" = {
allow-when-locked = true;
action.spawn = ["wpctl" "set-mute" "@DEFAULT_AUDIO_SINK@" "toggle"];
};
"XF86AudioMicMute" = {
allow-when-locked = true;
action.spawn = ["wpctl" "set-mute" "@DEFAULT_AUDIO_SOURCE@" "toggle"];
};
"XF86MonBrightnessUp" = {
allow-when-locked = true;
action.spawn = ["brillo" "-A" "5"];
};
"XF86MonBrightnessDown" = {
allow-when-locked = true;
action.spawn = ["brillo" "-U" "5"];
};
# Close windows.
"Mod+Q".action.close-window = {};
# Quit Niri.
"Mod+Shift+E".action.quit = {};
# Turn off monitors.
"Mod+Shift+Escape".action.power-off-monitors = {};
# Take a screenshot.
"Mod+P".action.screenshot = {};
"Mod+Shift+P".action.screenshot-screen = {};
"Mod+Shift+Ctrl+P".action.screenshot-window = {};
# Focus and move columns.
"Mod+H".action.focus-column-left = {};
"Mod+J".action.focus-window-down = {};
"Mod+K".action.focus-window-up = {};
"Mod+L".action.focus-column-right = {};
"Mod+Shift+H".action.move-column-left = {};
"Mod+Shift+J".action.move-window-down = {};
"Mod+Shift+K".action.move-window-up = {};
"Mod+Shift+L".action.move-column-right = {};
"Mod+Home".action.focus-column-first = {};
"Mod+End".action.focus-column-last = {};
"Mod+Shift+Home".action.move-column-to-first = {};
"Mod+Shift+End".action.move-column-to-last = {};
# Focus monitors.
"Mod+bracketleft".action.focus-monitor-left = {};
"Mod+bracketright".action.focus-monitor-right = {};
# Move columns between monitors.
"Mod+Shift+bracketleft".action.move-column-to-monitor-left = {};
"Mod+Shift+bracketright".action.move-column-to-monitor-right = {};
# Focus workspaces.
"Mod+U".action.focus-workspace-down = {};
"Mod+I".action.focus-workspace-up = {};
"Mod+1".action.focus-workspace = 1;
"Mod+2".action.focus-workspace = 2;
"Mod+3".action.focus-workspace = 3;
"Mod+4".action.focus-workspace = 4;
"Mod+5".action.focus-workspace = 5;
"Mod+6".action.focus-workspace = 6;
"Mod+7".action.focus-workspace = 7;
"Mod+8".action.focus-workspace = 8;
"Mod+9".action.focus-workspace = 9;
# Move columns to workspaces.
"Mod+Shift+U".action.move-column-to-workspace-down = {};
"Mod+Shift+I".action.move-column-to-workspace-up = {};
"Mod+Shift+1".action.move-column-to-workspace = 1;
"Mod+Shift+2".action.move-column-to-workspace = 2;
"Mod+Shift+3".action.move-column-to-workspace = 3;
"Mod+Shift+4".action.move-column-to-workspace = 4;
"Mod+Shift+5".action.move-column-to-workspace = 5;
"Mod+Shift+6".action.move-column-to-workspace = 6;
"Mod+Shift+7".action.move-column-to-workspace = 7;
"Mod+Shift+8".action.move-column-to-workspace = 8;
"Mod+Shift+9".action.move-column-to-workspace = 9;
# Expel & consume windows into columns.
"Mod+Comma".action.consume-window-into-column = {};
"Mod+Period".action.expel-window-from-column = {};
# Resize columns.
"Mod+R".action.switch-preset-column-width = {};
"Mod+Shift+R".action.reset-window-height = {};
"Mod+F".action.maximize-column = {};
"Mod+Shift+F".action.fullscreen-window = {};
"Mod+C".action.center-column = {};
"Mod+Minus".action.set-column-width = "-10%";
"Mod+Equal".action.set-column-width = "+10%";
"Mod+Shift+Minus".action.set-window-height = "-10%";
"Mod+Shift+Equal".action.set-window-height = "+10%";
};
layout = {
gaps = 4;
border.width = 1;
preset-column-widths = [
{proportion = 1.0 / 3.0;}
{proportion = 1.0 / 2.0;}
{proportion = 2.0 / 6.0;}
];
default-column-width = {
proportion = 1.0 / 2.0;
};
};
};
};
# Lock screen.
programs.hyprlock = {
enable = true;
settings = {
input-field = {
fade_on_empty = false;
rounding = 0;
outline_thickness = 1;
valign = "center";
halign = "center";
position = "0%, -10%";
size = "20%, 5%";
};
label = {
valign = "center";
halign = "center";
position = "0%, 10%";
text = "$TIME";
font_size = 128;
font_family = "Adwaita Sans Bold";
};
};
};
stylix.targets.hyprlock.useWallpaper = false;
# Auto-lock.
services.hypridle = {
enable = true;
settings = {
general.lock_cmd = "hyprlock";
listener = [
{
timeout = 300;
on-timeout = "brillo -O; brillo -u 500000 -S 10";
on-resume = "brillo -I -u 250000";
}
{
timeout = 600;
on-timeout = "loginctl lock-session";
}
];
};
};
# Launcher.
programs.fuzzel = {
enable = true;
settings = {
main = {
horizontal-pad = 8;
vertical-pad = 8;
inner-pad = 8;
};
border.radius = 0;
};
};
# Panel.
programs.waybar = {
enable = true;
systemd.enable = true;
style = ''
* {
border-radius: 0;
}
'';
settings.main = {
modules-left = ["niri/workspaces"];
modules-center = ["clock"];
modules-right = ["network" "wireplumber" "battery#0" "battery#1"];
"battery#0" = {
bat = "BAT0";
format-icons = ["󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂁" "󰂂" "󰁹"];
format = "{icon} {capacity}%";
tooltip = false;
};
"battery#1" = {
bat = "BAT1";
format-icons = ["󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂁" "󰂂" "󰁹"];
format = "{icon} {capacity}%";
tooltip = false;
};
"network" = {
format-icons = ["󰤯" "󰤟" "󰤢" "󰤥" "󰤨"];
format = "{icon}";
format-disconnected = "";
tooltip = true;
tooltip-format = "{essid}";
};
"wireplumber" = {
format-icons = ["" "" ""];
format = "{icon} {volume}%";
format-muted = " ";
tooltip = false;
};
"clock" = {
format = "{:%a %b %d · %H:%M}";
tooltip = false;
};
};
};
stylix.targets.waybar.font = "sansSerif"; # use sans-serif font, not monospaced.
# polkit-gnome.
systemd.user.services.polkit-gnome-authentication-agent-1 = {
Unit.Description = "polkit-gnome-authentication-agent-1";
Install = {
WantedBy = ["graphical-session.target"];
Wants = ["graphical-session.target"];
After = ["graphical-session.target"];
};
Service = {
Type = "simple";
ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1";
Restart = "on-failure";
RestartSec = 1;
TimeoutStopSec = 10;
};
};
# Wallpaper manager.
services.hyprpaper.enable = true;
# Notifications
services.mako.enable = true;
# Install some software.
programs.firefox = {
enable = true;
profiles.default = {};
};
stylix.targets.firefox.profileNames = ["default"];
programs.kitty = {
enable = true;
settings.window_padding_width = 4;
};
fonts.fontconfig.enable = true; # discover fonts installed by home.packages.
home.packages = with pkgs; [
caligula
celluloid
deploy-rs
discord
feishin
fluffychat
fusee-nano
gimp3
glabels-qt
jellyfin-media-player
libreoffice
nautilus
nerd-fonts.symbols-only
nextcloud-client
noto-fonts
noto-fonts-cjk-sans
noto-fonts-cjk-serif
ns-usbloader
obsidian
prismlauncher
protonmail-desktop
rockbox-utility
signal-desktop
smile
via
yubioath-flutter
];
}