nix/graphical/quick-services.nix
2025-09-09 08:12:26 +10:00

61 lines
1.4 KiB
Nix

{
config,
lib,
mainUser,
...
}:
{
options = {
quick = {
services =
with lib;
mkOption {
type = with types; attrsOf str;
default = { };
};
oneShots =
with lib;
mkOption {
type = with types; attrsOf str;
default = { };
};
};
};
config = {
systemd.user.services =
builtins.mapAttrs (name: cmd: {
environment.PATH = lib.mkForce "/run/current-system/sw/bin:/run/current-system/sw/sbin:/etc/profiles/per-user/${mainUser}/bin:/etc/profiles/per-user/${mainUser}/sbin";
unitConfig = {
Description = "${name}";
Requires = [
"graphical-session.target"
];
After = [
"graphical-session.target"
"niri.target"
];
PartOf = [ "graphical-session.target" ];
};
serviceConfig = {
ExecStart = cmd;
};
wantedBy = [ "graphical-session.target" ];
}) config.quick.services
// builtins.mapAttrs (name: cmd: {
unitConfig = {
Description = "${name}";
Requires = [ "graphical-session.target" ];
After = [
"graphical-session.target"
"niri.target"
];
};
serviceConfig = {
ExecStart = cmd;
Type = "oneshot";
};
wantedBy = [ "graphical-session.target" ];
}) config.quick.oneShots;
};
}