Files
nixos-blueprint/modules/home/desktop/niri/default.nix
2025-07-01 10:30:28 +03:00

211 lines
6.9 KiB
Nix

{
perSystem,
osConfig,
config,
inputs,
pkgs,
lib,
...
}: let
# inherit (lib.strings) removeSuffix;
inherit (lib) mkIf mkEnableOption mkDefault mkForce getExe;
inherit (config.lib.stylix) colors;
# inherit (osConfig.module.stylix) theme;
inherit (osConfig.networking) hostName;
cfg = config.desktop.niri;
ifLaptop = mkIf (hostName != "dunamis");
launcher = getExe pkgs.walker;
lockscreen = getExe pkgs.gtklock;
in {
imports = with inputs; [
walker.homeManagerModules.default
];
options = {
desktop.niri.enable =
mkEnableOption "enable niri desktop";
};
config = mkIf cfg.enable {
stylix.targets = {
waybar.enable = false;
wpaperd.enable = true;
qt.enable = false;
};
dconf.settings = {
"org/gnome/desktop/wm/preferences" = {
button-layout = "icon:close";
};
"org/gnome/desktop/interface" = {
icon-theme = config.gtk.iconTheme.name;
color-scheme =
if config.stylix.polarity == "dark"
then lib.mkDefault "prefer-dark"
else lib.mkDefault "prefer-light";
};
};
gtk = {
enable = true;
iconTheme = let
name =
if (lib.strings.hasPrefix "gruvbox" osConfig.module.stylix.theme)
then "Gruvbox-Plus-Dark"
else if config.stylix.polarity == "dark"
then "Papirus-Dark"
else "Papirus-Light";
package =
if (lib.strings.hasPrefix "gruvbox" osConfig.module.stylix.theme)
then pkgs.gruvbox-plus-icons
else if (lib.strings.hasPrefix "rose-pine" osConfig.module.stylix.theme)
then pkgs.papirus-icon-theme.override {color = "indigo";}
else if (lib.strings.hasPrefix "nord" osConfig.module.stylix.theme)
then pkgs.papirus-icon-theme.override {color = "nordic";}
else pkgs.papirus-icon-theme;
in {inherit name package;};
};
qt = {
enable = true;
platformTheme.name = "gtk3";
};
programs = {
walker = import ./programs/walker {inherit config inputs pkgs;};
waybar = import ./programs/waybar {inherit config colors getExe ifLaptop launcher pkgs;};
};
services = import ./services {inherit pkgs lockscreen getExe perSystem;};
home.packages = with pkgs;
[
# gui libadwaita apps
celluloid # mpv gui in libadwaita
gnome-text-editor
helvum # pipewire patchbay in rust
junction # app chooser
loupe # image viewer and editor in rust
mission-center # task manager in rust (partly)
nautilus # file manager
overskride # bluetooth gui in rust
papers # pdf reader in rust
pika-backup # borg gui in rust
pwvucontrol # pipewire gui in rust
sonusmix # pipewire routing tool in rust
wdisplays # wlroots display configurator
]
++ [
# misc utils
(ifLaptop brightnessctl)
dconf
libnotify
playerctl
wl-clipboard-rs # wl-clipboard in rust
];
xdg = {
configFile = {
niri = import ./niri.nix {inherit config hostName launcher lockscreen;};
"mimeapps.list".force = true;
};
mime.enable = true;
mimeApps = {
enable = true;
defaultApplications = let
file_manager = ["org.gnome.Nautilus.desktop"];
image_viewer = ["org.gnome.Loupe.desktop"];
pdf_reader = ["org.gnome.Papers.desktop"];
video_player = ["io.github.celluloid_player.Celluloid.desktop"];
web_browser = ["re.sonny.Junction.desktop"];
in {
"application/pdf" = pdf_reader;
"image/jpeg" = image_viewer;
"image/png" = image_viewer;
"inode/directory" = file_manager;
"text/html" = web_browser;
"video/mp4" = video_player;
"video/mpeg" = video_player;
"video/x-matroska" = video_player;
"video/x-mpeg" = video_player;
"x-scheme-handler/about" = web_browser;
"x-scheme-handler/http" = web_browser;
"x-scheme-handler/https" = web_browser;
"x-scheme-handler/unknown" = web_browser;
};
};
};
systemd.user = {
settings.Manager.DefaultEnvironment = {
QT_QPA_PLATFORM = "wayland";
DISPLAY = ":123";
};
targets.tray.Unit.Description = "Home Manager System Tray"; # workaround for udiskie
services = let
mkGraphicalService = config: graphicalService // config;
graphicalService = {
Install.WantedBy = ["niri.service"];
Unit = {
Requisite = ["graphical-session.target"];
PartOf = ["graphical-session.target"];
After = ["graphical-session.target"];
};
Service = {
Restart = "on-failure";
TimeoutStopSec = 10;
RestartSec = 1;
};
};
in
lib.mkMerge [
{
udiskie = mkGraphicalService {};
waybar = mkGraphicalService {};
network-manager-applet = mkGraphicalService {};
copyq = mkGraphicalService {
Service =
graphicalService.Service
// {
Environment = mkForce "QT_QPA_PLATFORM=wayland";
};
};
xwayland-satellite = mkGraphicalService {
Service =
graphicalService.Service
// {
Type = "simple";
ExecStart = getExe pkgs.xwayland-satellite + " :123";
};
};
wpaperd = mkGraphicalService {
Service =
mkDefault graphicalService.Service;
};
walker = mkGraphicalService {};
# gnome-polkit-agent = mkGraphicalService {
# Service =
# graphicalService.Service
# // {
# Type = "simple";
# ExecStart = pkgs.polkit_gnome + "/libexec/polkit-gnome-authentication-agent-1";
# };
# };
}
(lib.mkIf (hostName == "morphius") {
lisgd = mkGraphicalService {
Service =
graphicalService.Service
// {
# Group = "input";
Type = "simple";
ExecStart =
"${pkgs.lisgd}/bin/lisgd"
+ " -d /dev/input/by-path/pci-0000:00:15.1-platform-i2c_designware.1-event"
+ " -g \"1,DU,TL,*,P,niri msg action toggle-overview\""
+ " -g \"3,UD,T,*,P,niri msg action focus-workspace-up\""
+ " -g \"3,DU,B,*,P,niri msg action focus-workspace-down\""
+ " -g \"3,LR,L,*,P,niri msg action focus-column-left\""
+ " -g \"3,RL,R,*,P,niri msg action focus-column-right\"";
};
};
})
];
};
};
}