feat(niri): giving niri a test drive

This commit is contained in:
2025-09-12 20:47:08 +02:00
parent 65de9592a0
commit f6722f4986
19 changed files with 329 additions and 107 deletions

158
flake.lock generated
View File

@@ -1135,6 +1135,62 @@
"type": "github"
}
},
"niri": {
"inputs": {
"niri-stable": "niri-stable",
"niri-unstable": "niri-unstable",
"nixpkgs": "nixpkgs_8",
"nixpkgs-stable": "nixpkgs-stable",
"xwayland-satellite-stable": "xwayland-satellite-stable",
"xwayland-satellite-unstable": "xwayland-satellite-unstable"
},
"locked": {
"lastModified": 1757698528,
"narHash": "sha256-vXZaxm2LfFrVyuUOKkyWpwR0K2WB7k2oo94HN1o4910=",
"owner": "sodiboo",
"repo": "niri-flake",
"rev": "2418edea929640fb5f856bc0a25fb91f54dfc229",
"type": "github"
},
"original": {
"owner": "sodiboo",
"repo": "niri-flake",
"type": "github"
}
},
"niri-stable": {
"flake": false,
"locked": {
"lastModified": 1756556321,
"narHash": "sha256-RLD89dfjN0RVO86C/Mot0T7aduCygPGaYbog566F0Qo=",
"owner": "YaLTeR",
"repo": "niri",
"rev": "01be0e65f4eb91a9cd624ac0b76aaeab765c7294",
"type": "github"
},
"original": {
"owner": "YaLTeR",
"ref": "v25.08",
"repo": "niri",
"type": "github"
}
},
"niri-unstable": {
"flake": false,
"locked": {
"lastModified": 1757656821,
"narHash": "sha256-MDaLusQZflxngGMU41g6cqabM7KE8I55UazzAZsjNN0=",
"owner": "YaLTeR",
"repo": "niri",
"rev": "b7909dbf61c7c1511b9a51ef46e1d503d5ba3d05",
"type": "github"
},
"original": {
"owner": "YaLTeR",
"repo": "niri",
"type": "github"
}
},
"nix-gaming": {
"inputs": {
"flake-parts": [
@@ -1212,6 +1268,38 @@
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1757545623,
"narHash": "sha256-mCxPABZ6jRjUQx3bPP4vjA68ETbPLNz9V2pk9tO7pRQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8cd5ce828d5d1d16feff37340171a98fc3bf6526",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-25.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_10": {
"locked": {
"lastModified": 1756696532,
"narHash": "sha256-6FWagzm0b7I/IGigOv9pr6LL7NQ86mextfE8g8Q6HBg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "58dcbf1ec551914c3756c267b8b9c8c86baa1b2f",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1755186698,
@@ -1309,6 +1397,22 @@
}
},
"nixpkgs_8": {
"locked": {
"lastModified": 1757487488,
"narHash": "sha256-zwE/e7CuPJUWKdvvTCB7iunV4E/+G0lKfv4kk/5Izdg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ab0f3607a6c7486ea22229b92ed2d355f1482ee0",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_9": {
"locked": {
"lastModified": 1756787288,
"narHash": "sha256-rw/PHa1cqiePdBxhF66V7R+WAP8WekQ0mCDG4CFqT8Y=",
@@ -1324,28 +1428,12 @@
"type": "github"
}
},
"nixpkgs_9": {
"locked": {
"lastModified": 1756696532,
"narHash": "sha256-6FWagzm0b7I/IGigOv9pr6LL7NQ86mextfE8g8Q6HBg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "58dcbf1ec551914c3756c267b8b9c8c86baa1b2f",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nvf": {
"inputs": {
"flake-compat": "flake-compat_4",
"flake-parts": "flake-parts_5",
"mnw": "mnw",
"nixpkgs": "nixpkgs_9",
"nixpkgs": "nixpkgs_10",
"systems": "systems_4"
},
"locked": {
@@ -1430,8 +1518,9 @@
"hyprlock": "hyprlock",
"hyprpaper": "hyprpaper",
"lanzaboote": "lanzaboote",
"niri": "niri",
"nix-gaming": "nix-gaming",
"nixpkgs": "nixpkgs_8",
"nixpkgs": "nixpkgs_9",
"nvf": "nvf",
"systems": "systems_5",
"treefmt-nix": "treefmt-nix",
@@ -1692,6 +1781,39 @@
"type": "github"
}
},
"xwayland-satellite-stable": {
"flake": false,
"locked": {
"lastModified": 1755491097,
"narHash": "sha256-m+9tUfsmBeF2Gn4HWa6vSITZ4Gz1eA1F5Kh62B0N4oE=",
"owner": "Supreeeme",
"repo": "xwayland-satellite",
"rev": "388d291e82ffbc73be18169d39470f340707edaa",
"type": "github"
},
"original": {
"owner": "Supreeeme",
"ref": "v0.7",
"repo": "xwayland-satellite",
"type": "github"
}
},
"xwayland-satellite-unstable": {
"flake": false,
"locked": {
"lastModified": 1757179758,
"narHash": "sha256-TIvyWzRt1miQj6Cf5Wy8Qz43XIZX7c4vTVwRLAT5S4Y=",
"owner": "Supreeeme",
"repo": "xwayland-satellite",
"rev": "970728d0d9d1eada342bb8860af214b601139e58",
"type": "github"
},
"original": {
"owner": "Supreeeme",
"repo": "xwayland-satellite",
"type": "github"
}
},
"zen-browser": {
"inputs": {
"nixpkgs": [

View File

@@ -135,6 +135,8 @@
inputs.nixpkgs.follows = "nixpkgs";
};
niri.url = "github:sodiboo/niri-flake";
# Custom
tuirun = {
url = "git+https://git.sr.ht/~canasta/tuirun";

View File

@@ -74,8 +74,8 @@
enable = false;
};
hyprland = {
enable = true;
withUWSM = true;
enable = false;
withUWSM = false;
};
inkscape = {
enable = false;
@@ -89,6 +89,9 @@
microfetch = {
enable = true;
};
niri = {
enable = true;
};
pkgs = {
enable = true;
desktop = {

View File

@@ -76,6 +76,7 @@
./nixos/programs/lact
./nixos/programs/lutris
./nixos/programs/microfetch
./nixos/programs/niri
./nixos/programs/pkgs
./nixos/programs/mysql-workbench
./nixos/programs/nh

View File

@@ -22,7 +22,7 @@ in
main = {
layer = "overlay";
font = "Input Sans Narrow Light:size=12";
launch-prefix = "uwsm app --";
# launch-prefix = "uwsm app --";
lines = "8";
};
colors = {

View File

@@ -28,7 +28,7 @@ in
enableFishIntegration = config.programs.fish.enable;
enableZshIntegration = config.programs.zsh.enable;
settings = {
theme = "GruvboxDark";
theme = "GruvboxDarkHard";
focus-follows-mouse = true;
resize-overlay = "never";
background-opacity = 0.95;

View File

@@ -12,7 +12,7 @@ in
{
imports = [
./languages.nix
./gruvbox.nix
# ./gruvbox.nix
];
options = {
@@ -26,7 +26,7 @@ in
package = inputs.helix-flake.packages.${pkgs.system}.default;
settings = {
theme = "gruvbox_custom";
theme = "gruvbox_dark_hard";
editor = {
color-modes = true;
scrolloff = 0;

View File

@@ -1,7 +1,6 @@
{
inputs,
pkgs,
config,
lib,
osConfig,
cLib,
@@ -9,7 +8,7 @@
}:
let
inherit (lib) mkIf mkEnableOption;
cfg = config.home.programs.hyprlock;
cfg = osConfig.nixos.programs.hyprland;
hyprlockFlake = inputs.hyprlock.packages.${pkgs.system}.hyprlock;
# hyprlockPkg = pkgs.hyprlock;
@@ -18,9 +17,6 @@ let
inherit (cLib.theme.bgs) resolve;
in
{
options = {
home.programs.hyprlock.enable = mkEnableOption "Enables hyprlock";
};
config = mkIf cfg.enable {
programs.hyprlock = {
enable = true;

View File

@@ -1,5 +1,22 @@
[
{
"modules-left": [
"group/system"
],
"modules-center": [
"niri/workspaces"
],
"modules-right": [
"custom/progress",
"custom/systemd",
"group/tray",
"pulseaudio",
"backlight",
"battery",
"date",
"clock",
"custom/dunst"
],
"backlight": {
"format": "<span foreground='#928374'>{icon}</span> {percent}%",
"format-icons": [
@@ -128,6 +145,19 @@
"*": 3
}
},
"niri/workspaces": {
"format": "{icon}",
"format-icons": {
// Named workspaces
// (you need to configure them in niri)
"browser": "",
"discord": "",
"chat": "<b></b>",
// Icons by state
"active": "",
"default": ""
}
},
"memory": {
"format": "<span foreground='#928374'></span> {}%",
"states": {
@@ -135,23 +165,6 @@
"warning": 70
}
},
"modules-center": [
"hyprland/workspaces"
],
"modules-left": [
"group/system"
],
"modules-right": [
"custom/progress",
"custom/systemd",
"group/tray",
"pulseaudio",
"backlight",
"battery",
"date",
"clock",
"custom/dunst"
],
"network": {
"format-disconnected": " <span foreground='#928374'></span> ",
"format-ethernet": "<span foreground='#928374'></span> {ifname}",

View File

@@ -1,21 +1,18 @@
{
config,
osConfig,
lib,
pkgs,
inputs,
...
}:
let
inherit (lib) mkIf mkEnableOption;
cfg = config.home.services.hypridle;
inherit (lib) mkIf;
cfg = osConfig.nixos.programs.hyprland;
hypridleFlake = inputs.hypridle.packages.${pkgs.system}.hypridle;
# hypridlePkg = pkgs.hypridle;
in
{
options = {
home.services.hypridle.enable = mkEnableOption "Enables hypridle";
};
config = mkIf cfg.enable {
services.hypridle = {
enable = true;

View File

@@ -1,5 +1,4 @@
{
config,
lib,
pkgs,
inputs,
@@ -8,9 +7,9 @@
...
}:
let
inherit (lib) mkIf mkEnableOption;
inherit (lib) mkIf;
cfg = config.home.services.hyprpaper;
cfg = osConfig.nixos.programs.hyprland;
hyprpaperFlake = inputs.hyprpaper.packages.${pkgs.system}.default;
bg = osConfig.settings.theme.background;
bgs = cLib.theme.bgs;
@@ -35,10 +34,6 @@ let
];
in
{
options = {
home.services.hyprpaper.enable = mkEnableOption "Enable hyprpaper wallpaper service";
};
config = mkIf cfg.enable {
services.hyprpaper = {
enable = true;

View File

@@ -20,7 +20,14 @@ in
config = mkMerge [
(mkIf cfg.enable {
programs.fish.enable = true;
programs.fish = {
enable = true;
vendor = {
completions.enable = true;
config.enable = true;
functions.enable = true;
};
};
})
(mkIf cfg.homeless.enable {

View File

@@ -1,22 +0,0 @@
# Taken from Misterio77 https://github.com/Misterio77/nix-config/blob/main/home/gabriel/features/cli/fish/up-or-search.fish
# Merge history upon doing up-or-search
# This lets multiple fish instances share history
if commandline --search-mode
commandline -f history-search-backward
return
end
if commandline --paging-mode
commandline -f up-line
return
end
set -l lineno (commandline -L)
switch $lineno
case 1
commandline -f history-search-backward
# Here we go
history merge
case '*'
commandline -f up-line
end

View File

@@ -0,0 +1,24 @@
{
config,
inputs,
lib,
pkgs,
...
}:
let
inherit (lib) mkIf mkEnableOption;
cfg = config.nixos.programs.niri;
in
{
options = {
nixos.programs.niri.enable = mkEnableOption "Enables niri";
};
config = mkIf cfg.enable {
nixpkgs.overlays = [ inputs.niri.overlays.niri ];
systemd.user.services.niri-flake-polkit.enable = false;
programs.niri = {
enable = true;
package = pkgs.niri-unstable;
};
};
}

View File

@@ -1,6 +1,7 @@
{
config,
lib,
pkgs,
...
}:
let
@@ -9,8 +10,11 @@ let
mkEnableOption
mkOption
types
mkMerge
;
cfg = config.nixos.services.greetd;
hyprcfg = config.nixos.programs.hyprland;
niricfg = config.nixos.programs.niri;
in
{
options = {
@@ -28,21 +32,47 @@ in
};
};
config = mkIf cfg.enable {
services.greetd =
let
session = {
command = "${lib.getExe config.programs.uwsm.package} start hyprland-uwsm.desktop";
user = cfg.user;
config =
let
usernames = builtins.attrNames config.home-manager.users;
username = builtins.head usernames;
in
mkMerge [
(mkIf cfg.enable { services.greetd.enable = true; })
(mkIf hyprcfg.enable {
services.greetd =
let
session = {
command = "${lib.getExe config.programs.uwsm.package} start hyprland-uwsm.desktop";
user = cfg.user;
};
in
{
settings = {
terminal.vt = 1;
default_session = session;
initial_session = session;
};
};
})
(mkIf niricfg.enable {
services.greetd = {
enable = true;
settings = rec {
tuigreet_session =
let
session = "${pkgs.niri-unstable}/bin/niri-session";
tuigreet = "${lib.getExe pkgs.tuigreet}";
in
{
command = "${tuigreet} --time --remember --cmd ${session}";
user = "greeter";
};
default_session = tuigreet_session;
};
};
in
{
enable = true;
settings = {
terminal.vt = 1;
default_session = session;
initial_session = session;
};
};
};
})
];
}

View File

@@ -9,6 +9,7 @@
"https://nix-gaming.cachix.org"
"https://yazi.cachix.org"
"https://chaotic-nyx.cachix.org"
"https://niri.cachix.org"
];
trusted-public-keys = [
@@ -18,6 +19,7 @@
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4="
"niri.cachix.org-1:Wv0OmO7PsuocRKzfDoJ3mulSl7Z6oezYhGhR+3W2964="
"yazi.cachix.org-1:Dcdz63NZKfvUCbDGngQDAZq6kOroIrFoyO064uvLh8k="
"chaotic-nyx.cachix.org-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8"
];

51
scripts/bin/spawn-or-focus.sh Executable file
View File

@@ -0,0 +1,51 @@
# Check if at least one argument is provided
if [ $# -lt 1 ]; then
notify-send -t 5000 "Usage: spawn-or-focus.sh <APP_CLASS> [APP_CMD]"
exit 1
fi
APP_CLASS="$1" # Application's app_id (e.g. firefox)
APP_CMD="${2:-}" # Optional: Command to run the application
# Get the ID of the currently focused window
FOCUSED_ID=$(niri msg -j focused-window | jq -r '.id')
# Find windows matching the app class and read them into an array
readarray -t MATCHING_IDS < <(
niri msg -j windows |
jq -r --arg app_class "$APP_CLASS" '
.[]
| select(.app_id | ascii_downcase | contains($app_class | ascii_downcase))
| .id
'
)
# Launch the app and exit the script if the number of matching windows is zero
if [ ${#MATCHING_IDS[@]} -eq 0 ]; then
# Use the app class as the command if no app command is supplied
if [ -z "$APP_CMD" ]; then
APP_CMD="$APP_CLASS"
fi
"$APP_CMD" &
exit 0
fi
# Find the array index of the currently focused window
CURRENT_INDEX=-1
for INDEX in "${!MATCHING_IDS[@]}"; do
if [ "${MATCHING_IDS[$INDEX]}" = "$FOCUSED_ID" ]; then
CURRENT_INDEX=$INDEX
break
fi
done
# Cycle to the next matching array index if the currently focused ID was found
# in the array, otherwise set the target index to zero
if [ "$CURRENT_INDEX" -ge 0 ]; then
TARGET_INDEX=$(((CURRENT_INDEX + 1) % ${#MATCHING_IDS[@]}))
else
TARGET_INDEX=0
fi
# Switch focus to the target window stored in the array
niri msg action focus-window --id "${MATCHING_IDS[$TARGET_INDEX]}"

View File

@@ -14,6 +14,16 @@ in
sessionPath = [ "${config.home.homeDirectory}/.local/bin" ];
file = {
".local/bin/spawn-or-focus.sh" = {
source = getExe (
pkgs.writeShellApplication {
name = "spawn-or-focus";
runtimeInputs = with pkgs; [ niri ];
text = readFile ./bin/spawn-or-focus.sh;
}
);
};
".local/bin/pavucontrol-toggle.sh" = {
source = getExe (
pkgs.writeShellApplication {

View File

@@ -44,9 +44,6 @@
helix = {
enable = true;
};
hyprlock = {
enable = true;
};
jujutsu = {
enable = false;
};
@@ -128,12 +125,6 @@
gtk = {
enable = true;
};
hypridle = {
enable = true;
};
hyprpaper = {
enable = true;
};
mako = {
enable = false;
};