feat: add new wayland compositor - niri

This commit is contained in:
Ryan Yin
2025-08-18 21:44:18 +08:00
parent 09fbea3f77
commit 69eee64e7e
52 changed files with 333 additions and 89 deletions

View File

@@ -124,6 +124,14 @@ hypr mode="default":
use {{utils_nu}} *;
nixos-switch $"(hostname)-hyprland" {{mode}}
# Deploy the niri nixosConfiguration by hostname match
[linux]
[group('desktop')]
niri mode="default":
#!/usr/bin/env nu
use {{utils_nu}} *;
nixos-switch $"(hostname)-niri" {{mode}}
############################################################################
#
# Darwin related commands

126
flake.lock generated
View File

@@ -539,6 +539,62 @@
"url": "ssh://git@github.com/ryan4yin/nix-secrets.git"
}
},
"niri": {
"inputs": {
"niri-stable": "niri-stable",
"niri-unstable": "niri-unstable",
"nixpkgs": "nixpkgs_2",
"nixpkgs-stable": "nixpkgs-stable_2",
"xwayland-satellite-stable": "xwayland-satellite-stable",
"xwayland-satellite-unstable": "xwayland-satellite-unstable"
},
"locked": {
"lastModified": 1755424351,
"narHash": "sha256-xcorYLNdtLpb0wH5CPlUcpmYQUxeK95j1X855xQw+DY=",
"owner": "sodiboo",
"repo": "niri-flake",
"rev": "9aa137af01f05386e5bb5050e983750017007a66",
"type": "github"
},
"original": {
"owner": "sodiboo",
"repo": "niri-flake",
"type": "github"
}
},
"niri-stable": {
"flake": false,
"locked": {
"lastModified": 1748151941,
"narHash": "sha256-z4viQZLgC2bIJ3VrzQnR+q2F3gAOEQpU1H5xHtX/2fs=",
"owner": "YaLTeR",
"repo": "niri",
"rev": "8ba57fcf25d2fc9565131684a839d58703f1dae7",
"type": "github"
},
"original": {
"owner": "YaLTeR",
"ref": "v25.05.1",
"repo": "niri",
"type": "github"
}
},
"niri-unstable": {
"flake": false,
"locked": {
"lastModified": 1755419373,
"narHash": "sha256-EFH3zbpyLYjEboNV2Lmkxf9joEuFCmeYX+MMLRPStpg=",
"owner": "YaLTeR",
"repo": "niri",
"rev": "a6febb86aa5af0df7bf2792ca027ef95a503d599",
"type": "github"
},
"original": {
"owner": "YaLTeR",
"repo": "niri",
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
@@ -738,6 +794,22 @@
}
},
"nixpkgs-stable_2": {
"locked": {
"lastModified": 1755274400,
"narHash": "sha256-rTInmnp/xYrfcMZyFMH3kc8oko5zYfxsowaLv1LVobY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ad7196ae55c295f53a7d1ec39e4a06d922f3b899",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-25.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable_3": {
"locked": {
"lastModified": 1755274400,
"narHash": "sha256-rTInmnp/xYrfcMZyFMH3kc8oko5zYfxsowaLv1LVobY=",
@@ -770,6 +842,22 @@
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1755186698,
"narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1755186698,
"narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=",
@@ -919,15 +1007,16 @@
"lanzaboote": "lanzaboote",
"my-asahi-firmware": "my-asahi-firmware",
"mysecrets": "mysecrets",
"niri": "niri",
"nix-darwin": "nix-darwin",
"nix-gaming": "nix-gaming",
"nixos-apple-silicon": "nixos-apple-silicon",
"nixos-generators": "nixos-generators",
"nixpak": "nixpak",
"nixpkgs": "nixpkgs_2",
"nixpkgs": "nixpkgs_3",
"nixpkgs-darwin": "nixpkgs-darwin",
"nixpkgs-ollama": "nixpkgs-ollama",
"nixpkgs-stable": "nixpkgs-stable_2",
"nixpkgs-stable": "nixpkgs-stable_3",
"nixpkgs-unstable": "nixpkgs-unstable",
"nuenv": "nuenv",
"nur-ryan4yin": "nur-ryan4yin",
@@ -1077,6 +1166,39 @@
"type": "github"
}
},
"xwayland-satellite-stable": {
"flake": false,
"locked": {
"lastModified": 1748488455,
"narHash": "sha256-IiLr1alzKFIy5tGGpDlabQbe6LV1c9ABvkH6T5WmyRI=",
"owner": "Supreeeme",
"repo": "xwayland-satellite",
"rev": "3ba30b149f9eb2bbf42cf4758d2158ca8cceef73",
"type": "github"
},
"original": {
"owner": "Supreeeme",
"ref": "v0.6",
"repo": "xwayland-satellite",
"type": "github"
}
},
"xwayland-satellite-unstable": {
"flake": false,
"locked": {
"lastModified": 1755219541,
"narHash": "sha256-yKV6xHaPbEbh5RPxAJnb9yTs1wypr7do86hFFGQm1w8=",
"owner": "Supreeeme",
"repo": "xwayland-satellite",
"rev": "5a184d435927c3423f0ad189ea2b490578450fb7",
"type": "github"
},
"original": {
"owner": "Supreeeme",
"repo": "xwayland-satellite",
"type": "github"
}
},
"zig": {
"inputs": {
"flake-compat": [

View File

@@ -143,6 +143,8 @@
inputs.nixpkgs.follows = "nixpkgs";
};
niri.url = "github:sodiboo/niri-flake";
######################## Some non-flake repositories #########################################
polybar-themes = {

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@@ -0,0 +1,56 @@
{
config,
pkgs,
...
}:
{
imports = [
./anyrun.nix
];
home.packages = with pkgs; [
swaybg # the wallpaper
wl-clipboard # copying and pasting
hyprpicker # color picker
brightnessctl
hyprshot # screen shot
wf-recorder # screen recording
# audio
alsa-utils # provides amixer/alsamixer/...
networkmanagerapplet # provide GUI app: nm-connection-editor
];
xdg.configFile =
let
mkSymlink = config.lib.file.mkOutOfStoreSymlink;
confPath = "${config.home.homeDirectory}/nix-config/home/linux/gui/base/desktop/conf";
in
{
"mako".source = mkSymlink "${confPath}/mako";
"waybar".source = mkSymlink "${confPath}/waybar";
"wlogout".source = mkSymlink "${confPath}/wlogout";
"hypr/hypridle.conf".source = mkSymlink "${confPath}/hypridle.conf";
};
# status bar
programs.waybar = {
enable = true;
systemd.enable = true;
};
# Disable catppuccin to avoid conflict with my non-nix config.
catppuccin.waybar.enable = false;
# screen locker
programs.swaylock.enable = true;
# Logout Menu
programs.wlogout.enable = true;
catppuccin.wlogout.enable = false;
# Hyprland idle daemon
services.hypridle.enable = true;
# notification daemon, the same as dunst
services.mako.enable = true;
catppuccin.mako.enable = false;
}

View File

@@ -2,7 +2,6 @@
pkgs,
config,
lib,
anyrun,
...
}@args:
with lib;
@@ -11,7 +10,6 @@ let
in
{
imports = [
# anyrun.homeManagerModules.default # the module is already in hm now.
./options
];

View File

@@ -1,6 +1,5 @@
{
pkgs,
pkgs-stable,
config,
...
}:
@@ -11,38 +10,12 @@ in
xdg.configFile =
let
mkSymlink = config.lib.file.mkOutOfStoreSymlink;
hyprPath = "${config.home.homeDirectory}/nix-config/home/linux/gui/hyprland/conf";
confPath = "${config.home.homeDirectory}/nix-config/home/linux/gui/hyprland/conf";
in
{
"mako".source = mkSymlink "${hyprPath}/mako";
"waybar".source = mkSymlink "${hyprPath}/waybar";
"wlogout".source = mkSymlink "${hyprPath}/wlogout";
"hypr/hypridle.conf".source = mkSymlink "${hyprPath}/hypridle.conf";
"hypr/configs".source = mkSymlink "${hyprPath}/configs";
"hypr/configs".source = mkSymlink confPath;
};
# status bar
programs.waybar = {
enable = true;
systemd.enable = true;
};
# Disable catppuccin to avoid conflict with my non-nix config.
catppuccin.waybar.enable = false;
# screen locker
programs.swaylock.enable = true;
# Logout Menu
programs.wlogout.enable = true;
catppuccin.wlogout.enable = false;
# Hyprland idle daemon
services.hypridle.enable = true;
# notification daemon, the same as dunst
services.mako.enable = true;
catppuccin.mako.enable = false;
# NOTE:
# We have to enable hyprland/i3's systemd user service in home-manager,
# so that gammastep/wallpaper-switcher's user service can be start correctly!

View File

@@ -1,20 +0,0 @@
{
pkgs,
...
}:
{
home.packages = with pkgs; [
swaybg # the wallpaper
wl-clipboard # copying and pasting
hyprpicker # color picker
brightnessctl
hyprshot # screen shot
wf-recorder # screen recording
# audio
alsa-utils # provides amixer/alsamixer/...
networkmanagerapplet # provide GUI app: nm-connection-editor
];
}

View File

@@ -0,0 +1,66 @@
{
pkgs,
config,
lib,
...
}@args:
with lib;
let
cfg = config.modules.desktop.niri;
in
{
options.modules.desktop.niri = {
enable = mkEnableOption "niri compositor";
settings = lib.mkOption {
type =
with lib.types;
let
valueType =
nullOr (oneOf [
bool
int
float
str
path
(attrsOf valueType)
(listOf valueType)
])
// {
description = "niri configuration value";
};
in
valueType;
default = { };
};
};
config = mkIf cfg.enable (mkMerge ([
{
programs.wlogout.enable = true;
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
];
# NOTE: this executable is used by greetd to start a wayland session when system boot up
# with such a vendor-no-locking script, we can switch to another wayland compositor without modifying greetd's config in NixOS module
home.file.".wayland-session" = {
source = pkgs.writeScript "init-session" ''
# trying to stop a previous niri session
systemctl --user is-active niri.service && systemctl --user stop niri.service
# and then we start a new one
/run/current-system/sw/bin/niri-session
'';
executable = true;
};
}
]
# ++ (import ./values args)
));
}

View File

@@ -14,17 +14,26 @@ let
# Shoukei (祥瓊, Shōkei)
name = "shoukei";
base-modules = {
nixos-modules = map mylib.relativeToRoot [
# common
"secrets/nixos.nix"
"modules/nixos/desktop.nix"
# host specific
"hosts/12kingdoms-${name}"
# nixos hardening
# "hardening/profiles/default.nix"
"hardening/nixpaks"
"hardening/bwraps"
];
nixos-modules =
(map mylib.relativeToRoot [
# common
"secrets/nixos.nix"
"modules/nixos/desktop.nix"
# host specific
"hosts/12kingdoms-${name}"
# nixos hardening
# "hardening/profiles/default.nix"
"hardening/nixpaks"
"hardening/bwraps"
])
++ [
{
modules.desktop.fonts.enable = true;
modules.desktop.wayland.enable = true;
modules.secrets.desktop.enable = true;
modules.secrets.preservation.enable = true;
}
];
home-modules = map mylib.relativeToRoot [
# common
"home/linux/gui.nix"
@@ -35,14 +44,6 @@ let
modules-hyprland = {
nixos-modules = [
{
modules.desktop.wayland.enable = true;
modules.secrets.desktop.enable = true;
modules.secrets.preservation.enable = true;
# TODO: remove this option
nixpkgs.config.allowUnsupportedSstem = true;
}
]
++ base-modules.nixos-modules;
home-modules = [
@@ -50,15 +51,29 @@ let
]
++ base-modules.home-modules;
};
modules-niri = {
nixos-modules = [
inputs.niri.nixosModules.niri
{ programs.niri.enable = true; }
]
++ base-modules.nixos-modules;
home-modules = [
{ modules.desktop.niri.enable = true; }
]
++ base-modules.home-modules;
};
in
{
nixosConfigurations = {
# host with hyprland compositor
"${name}-hyprland" = mylib.nixosSystem (modules-hyprland // args);
"${name}-niri" = mylib.nixosSystem (modules-niri // args);
};
# generate iso image for hosts with desktop environment
packages = {
"${name}-hyprland" = inputs.self.nixosConfigurations."${name}-hyprland".config.formats.iso;
"${name}-niri" = inputs.self.nixosConfigurations."${name}-niri".config.formats.iso;
};
}

View File

@@ -6,6 +6,7 @@ let
username = myvars.username;
hosts = [
"shoukei-hyprland"
"shoukei-niri"
];
in
lib.genAttrs hosts (_: "/home/${username}")

View File

@@ -7,6 +7,7 @@ let
username = myvars.username;
hosts = [
"shoukei-hyprland"
"shoukei-niri"
];
in
lib.genAttrs hosts (

View File

@@ -5,6 +5,7 @@
let
specialExpected = {
"shoukei-hyprland" = "shoukei";
"shoukei-niri" = "shoukei";
};
specialHostNames = builtins.attrNames specialExpected;

View File

@@ -8,23 +8,33 @@
mylib,
system,
genSpecialArgs,
niri,
...
}@args:
let
# 星野 アイ, Hoshino Ai
name = "ai";
base-modules = {
nixos-modules = map mylib.relativeToRoot [
# common
"secrets/nixos.nix"
"modules/nixos/desktop.nix"
# host specific
"hosts/idols-${name}"
# nixos hardening
# "hardening/profiles/default.nix"
"hardening/nixpaks"
"hardening/bwraps"
];
nixos-modules =
(map mylib.relativeToRoot [
# common
"secrets/nixos.nix"
"modules/nixos/desktop.nix"
# host specific
"hosts/idols-${name}"
# nixos hardening
# "hardening/profiles/default.nix"
"hardening/nixpaks"
"hardening/bwraps"
])
++ [
{
modules.desktop.fonts.enable = true;
modules.desktop.wayland.enable = true;
modules.secrets.desktop.enable = true;
modules.secrets.preservation.enable = true;
}
];
home-modules = map mylib.relativeToRoot [
# common
"home/linux/gui.nix"
@@ -35,12 +45,6 @@ let
modules-hyprland = {
nixos-modules = [
{
modules.desktop.fonts.enable = true;
modules.desktop.wayland.enable = true;
modules.secrets.desktop.enable = true;
modules.secrets.preservation.enable = true;
}
]
++ base-modules.nixos-modules;
home-modules = [
@@ -48,15 +52,29 @@ let
]
++ base-modules.home-modules;
};
modules-niri = {
nixos-modules = [
inputs.niri.nixosModules.niri
{ programs.niri.enable = true; }
]
++ base-modules.nixos-modules;
home-modules = [
{ modules.desktop.niri.enable = true; }
]
++ base-modules.home-modules;
};
in
{
nixosConfigurations = {
# host with hyprland compositor
"${name}-hyprland" = mylib.nixosSystem (modules-hyprland // args);
"${name}-niri" = mylib.nixosSystem (modules-niri // args);
};
# generate iso image for hosts with desktop environment
packages = {
"${name}-hyprland" = inputs.self.nixosConfigurations."${name}-hyprland".config.formats.iso;
"${name}-niri" = inputs.self.nixosConfigurations."${name}-niri".config.formats.iso;
};
}

View File

@@ -6,6 +6,7 @@ let
username = myvars.username;
hosts = [
"ai-hyprland"
"ai-niri"
"ruby"
"k3s-prod-1-master-1"
];

View File

@@ -7,6 +7,7 @@ let
username = myvars.username;
hosts = [
"ai-hyprland"
"ai-niri"
"ruby"
"k3s-prod-1-master-1"
];

View File

@@ -5,6 +5,7 @@
let
specialExpected = {
"ai-hyprland" = "ai";
"ai-niri" = "ai";
};
specialHostNames = builtins.attrNames specialExpected;