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}} *; use {{utils_nu}} *;
nixos-switch $"(hostname)-hyprland" {{mode}} 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 # Darwin related commands

126
flake.lock generated
View File

@@ -539,6 +539,62 @@
"url": "ssh://git@github.com/ryan4yin/nix-secrets.git" "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": { "nix-darwin": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@@ -738,6 +794,22 @@
} }
}, },
"nixpkgs-stable_2": { "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": { "locked": {
"lastModified": 1755274400, "lastModified": 1755274400,
"narHash": "sha256-rTInmnp/xYrfcMZyFMH3kc8oko5zYfxsowaLv1LVobY=", "narHash": "sha256-rTInmnp/xYrfcMZyFMH3kc8oko5zYfxsowaLv1LVobY=",
@@ -770,6 +842,22 @@
} }
}, },
"nixpkgs_2": { "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": { "locked": {
"lastModified": 1755186698, "lastModified": 1755186698,
"narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=", "narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=",
@@ -919,15 +1007,16 @@
"lanzaboote": "lanzaboote", "lanzaboote": "lanzaboote",
"my-asahi-firmware": "my-asahi-firmware", "my-asahi-firmware": "my-asahi-firmware",
"mysecrets": "mysecrets", "mysecrets": "mysecrets",
"niri": "niri",
"nix-darwin": "nix-darwin", "nix-darwin": "nix-darwin",
"nix-gaming": "nix-gaming", "nix-gaming": "nix-gaming",
"nixos-apple-silicon": "nixos-apple-silicon", "nixos-apple-silicon": "nixos-apple-silicon",
"nixos-generators": "nixos-generators", "nixos-generators": "nixos-generators",
"nixpak": "nixpak", "nixpak": "nixpak",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_3",
"nixpkgs-darwin": "nixpkgs-darwin", "nixpkgs-darwin": "nixpkgs-darwin",
"nixpkgs-ollama": "nixpkgs-ollama", "nixpkgs-ollama": "nixpkgs-ollama",
"nixpkgs-stable": "nixpkgs-stable_2", "nixpkgs-stable": "nixpkgs-stable_3",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",
"nuenv": "nuenv", "nuenv": "nuenv",
"nur-ryan4yin": "nur-ryan4yin", "nur-ryan4yin": "nur-ryan4yin",
@@ -1077,6 +1166,39 @@
"type": "github" "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": { "zig": {
"inputs": { "inputs": {
"flake-compat": [ "flake-compat": [

View File

@@ -143,6 +143,8 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
niri.url = "github:sodiboo/niri-flake";
######################## Some non-flake repositories ######################################### ######################## Some non-flake repositories #########################################
polybar-themes = { 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, pkgs,
config, config,
lib, lib,
anyrun,
... ...
}@args: }@args:
with lib; with lib;
@@ -11,7 +10,6 @@ let
in in
{ {
imports = [ imports = [
# anyrun.homeManagerModules.default # the module is already in hm now.
./options ./options
]; ];

View File

@@ -1,6 +1,5 @@
{ {
pkgs, pkgs,
pkgs-stable,
config, config,
... ...
}: }:
@@ -11,38 +10,12 @@ in
xdg.configFile = xdg.configFile =
let let
mkSymlink = config.lib.file.mkOutOfStoreSymlink; 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 in
{ {
"mako".source = mkSymlink "${hyprPath}/mako"; "hypr/configs".source = mkSymlink confPath;
"waybar".source = mkSymlink "${hyprPath}/waybar";
"wlogout".source = mkSymlink "${hyprPath}/wlogout";
"hypr/hypridle.conf".source = mkSymlink "${hyprPath}/hypridle.conf";
"hypr/configs".source = mkSymlink "${hyprPath}/configs";
}; };
# 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: # NOTE:
# We have to enable hyprland/i3's systemd user service in home-manager, # 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! # 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) # Shoukei (祥瓊, Shōkei)
name = "shoukei"; name = "shoukei";
base-modules = { base-modules = {
nixos-modules = map mylib.relativeToRoot [ nixos-modules =
# common (map mylib.relativeToRoot [
"secrets/nixos.nix" # common
"modules/nixos/desktop.nix" "secrets/nixos.nix"
# host specific "modules/nixos/desktop.nix"
"hosts/12kingdoms-${name}" # host specific
# nixos hardening "hosts/12kingdoms-${name}"
# "hardening/profiles/default.nix" # nixos hardening
"hardening/nixpaks" # "hardening/profiles/default.nix"
"hardening/bwraps" "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 [ home-modules = map mylib.relativeToRoot [
# common # common
"home/linux/gui.nix" "home/linux/gui.nix"
@@ -35,14 +44,6 @@ let
modules-hyprland = { modules-hyprland = {
nixos-modules = [ 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; ++ base-modules.nixos-modules;
home-modules = [ home-modules = [
@@ -50,15 +51,29 @@ let
] ]
++ base-modules.home-modules; ++ 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 in
{ {
nixosConfigurations = { nixosConfigurations = {
# host with hyprland compositor # host with hyprland compositor
"${name}-hyprland" = mylib.nixosSystem (modules-hyprland // args); "${name}-hyprland" = mylib.nixosSystem (modules-hyprland // args);
"${name}-niri" = mylib.nixosSystem (modules-niri // args);
}; };
# generate iso image for hosts with desktop environment # generate iso image for hosts with desktop environment
packages = { packages = {
"${name}-hyprland" = inputs.self.nixosConfigurations."${name}-hyprland".config.formats.iso; "${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; username = myvars.username;
hosts = [ hosts = [
"shoukei-hyprland" "shoukei-hyprland"
"shoukei-niri"
]; ];
in in
lib.genAttrs hosts (_: "/home/${username}") lib.genAttrs hosts (_: "/home/${username}")

View File

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

View File

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

View File

@@ -8,23 +8,33 @@
mylib, mylib,
system, system,
genSpecialArgs, genSpecialArgs,
niri,
... ...
}@args: }@args:
let let
# 星野 アイ, Hoshino Ai # 星野 アイ, Hoshino Ai
name = "ai"; name = "ai";
base-modules = { base-modules = {
nixos-modules = map mylib.relativeToRoot [ nixos-modules =
# common (map mylib.relativeToRoot [
"secrets/nixos.nix" # common
"modules/nixos/desktop.nix" "secrets/nixos.nix"
# host specific "modules/nixos/desktop.nix"
"hosts/idols-${name}" # host specific
# nixos hardening "hosts/idols-${name}"
# "hardening/profiles/default.nix" # nixos hardening
"hardening/nixpaks" # "hardening/profiles/default.nix"
"hardening/bwraps" "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 [ home-modules = map mylib.relativeToRoot [
# common # common
"home/linux/gui.nix" "home/linux/gui.nix"
@@ -35,12 +45,6 @@ let
modules-hyprland = { modules-hyprland = {
nixos-modules = [ 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; ++ base-modules.nixos-modules;
home-modules = [ home-modules = [
@@ -48,15 +52,29 @@ let
] ]
++ base-modules.home-modules; ++ 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 in
{ {
nixosConfigurations = { nixosConfigurations = {
# host with hyprland compositor # host with hyprland compositor
"${name}-hyprland" = mylib.nixosSystem (modules-hyprland // args); "${name}-hyprland" = mylib.nixosSystem (modules-hyprland // args);
"${name}-niri" = mylib.nixosSystem (modules-niri // args);
}; };
# generate iso image for hosts with desktop environment # generate iso image for hosts with desktop environment
packages = { packages = {
"${name}-hyprland" = inputs.self.nixosConfigurations."${name}-hyprland".config.formats.iso; "${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; username = myvars.username;
hosts = [ hosts = [
"ai-hyprland" "ai-hyprland"
"ai-niri"
"ruby" "ruby"
"k3s-prod-1-master-1" "k3s-prod-1-master-1"
]; ];

View File

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

View File

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