refactor niri config and put fcitx and satellite into systemd service

This commit is contained in:
ulic-youthlic 2025-05-09 14:55:35 +08:00
parent cf70828749
commit dfe2db681d
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
7 changed files with 98 additions and 9 deletions

View file

@ -2,7 +2,7 @@
inherit (inputs.niri-flake.lib.kdl) node leaf plain flag;
in {
david.programs.niri = {
enable = true;
DISPLAY = ":1";
extraConfig = let
output = node "output";
in [

View file

@ -2,6 +2,7 @@
inherit (inputs.niri-flake.lib.kdl) node leaf plain flag;
in {
david.programs.niri = {
DISPLAY = ":1";
extraConfig = let
output = node "output";
in [

View file

@ -3,5 +3,7 @@
./openssh.nix
./niri
./wluma
./xwayland-satellite.nix
./fcitx5-reload.nix
];
}

View file

@ -0,0 +1,33 @@
{
lib,
config,
pkgs,
osConfig ? null,
...
}: let
cfg = config.david.programs.fcitx5-reload;
fcitx5 = lib.getExe' osConfig.i18n.inputMethod.package "fcitx5";
in {
options = {
david.programs.fcitx5-reload = {
enable = lib.mkEnableOption "fcitx5-reload";
};
};
config = lib.mkIf cfg.enable {
systemd.user.services = {
"fcitx5-reload" = {
Install = {
WantedBy = ["graphical-session.target"];
};
Unit = {
PartOf = ["graphical-session.target"];
After = ["graphical-session.target"];
};
Service = {
ExecStart = "${fcitx5} --replace";
Restart = "on-failure";
};
};
};
};
}

View file

@ -2,8 +2,8 @@
config,
pkgs,
lib,
osConfig,
inputs,
DISPLAY,
...
}: let
inherit (lib) getExe getExe';
@ -26,19 +26,15 @@
plain
;
DISPLAY = ":1";
bash = getExe config.programs.bash.package;
swaylock = getExe config.programs.swaylock.package;
fuzzel = getExe config.programs.fuzzel.package;
waybar = getExe config.programs.waybar.package;
swaync = getExe config.services.swaync.package;
fcitx5 = getExe' osConfig.i18n.inputMethod.package "fcitx5";
polkit-kde-agent = getExe' pkgs.kdePackages.polkit-kde-agent-1 "polkit-kde-agent";
wpctl = getExe' pkgs.wireplumber "wpctl";
swaybg = getExe pkgs.swaybg;
xwayland-satellite = getExe pkgs.xwayland-satellite;
ghostty = getExe config.programs.ghostty.package;
wl-paste = getExe' pkgs.wl-clipboard "wl-paste";
wl-copy = getExe' pkgs.wl-clipboard "wl-copy";
@ -390,8 +386,6 @@ in
(spawn-at-startup [waybar])
(spawn-at-startup [swaync])
(spawn-at-startup [swaybg "-i" "${config.home.homeDirectory}/wallpaper/01.png"])
(spawn-at-startup [fcitx5 "-d" "--replace"])
(spawn-at-startup [xwayland-satellite DISPLAY])
(spawn-at-startup [polkit-kde-agent])
(spawn-at-startup [wl-paste "--watch" cliphist "store"])
(plain "input" [

View file

@ -13,6 +13,9 @@ in {
extraConfig = lib.mkOption {
type = inputs.niri-flake.lib.kdl.types.kdl-document;
};
DISPLAY = lib.mkOption {
type = lib.types.str;
};
};
};
config = lib.mkMerge [
@ -21,9 +24,30 @@ in {
}
(
lib.mkIf cfg.enable {
home.sessionVariables = {
inherit (cfg) DISPLAY;
};
david.programs = {
xwayland-satellite = {
inherit (cfg) DISPLAY;
enable = true;
};
fcitx5-reload = {
enable = true;
};
};
systemd.user.services = {
"fcitx5-reload".Unit.After = ["xwayland-satellite.service"];
"xwayland-satellite".Unit.Before = ["fcitx5-reload.service"];
};
youthlic.programs.niri = {
# settings = lib.mkMerge [(import ./settings.nix args) cfg.settings];
config = (lib.toList (import ./config.nix args)) ++ (lib.toList cfg.extraConfig);
config =
(lib.toList (import ./config.nix (args
// {
inherit (cfg) DISPLAY;
})))
++ (lib.toList cfg.extraConfig);
};
david.programs.wluma.enable = true;
}

View file

@ -0,0 +1,35 @@
{
lib,
config,
pkgs,
...
}: let
cfg = config.david.programs.xwayland-satellite;
in {
options = {
david.programs.xwayland-satellite = {
enable = lib.mkEnableOption "xwayland-satellite";
DISPLAY = lib.mkOption {
type = lib.types.str;
example = ":1";
};
};
};
config = lib.mkIf cfg.enable {
systemd.user = {
services."xwayland-satellite" = {
Install = {
WantedBy = ["graphical-session.target"];
};
Unit = {
PartOf = ["graphical-session.target"];
After = ["graphical-session.target"];
};
Service = {
ExecStart = "${lib.getExe pkgs.xwayland-satellite} ${cfg.DISPLAY}";
Restart = "on-failure";
};
};
};
};
}