mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
`literalExpression` is intended just to signify code that needs to stay a string that gets represented exactly as-is for docs. It has been misused heavily and people get confused repeatedly on when or not to use it because of the rampant misuse.
116 lines
2.8 KiB
Nix
116 lines
2.8 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.hypridle;
|
|
in
|
|
{
|
|
meta.maintainers = with lib.maintainers; [
|
|
khaneliman
|
|
fufexan
|
|
];
|
|
|
|
options.services.hypridle = {
|
|
enable = lib.mkEnableOption "Hypridle, Hyprland's idle daemon";
|
|
|
|
package = lib.mkPackageOption pkgs "hypridle" { nullable = true; };
|
|
|
|
settings = lib.mkOption {
|
|
type =
|
|
with lib.types;
|
|
let
|
|
valueType =
|
|
nullOr (oneOf [
|
|
bool
|
|
int
|
|
float
|
|
str
|
|
path
|
|
(attrsOf valueType)
|
|
(listOf valueType)
|
|
])
|
|
// {
|
|
description = "Hypridle configuration value";
|
|
};
|
|
in
|
|
valueType;
|
|
default = { };
|
|
description = ''
|
|
Hypridle configuration written in Nix. Entries with the same key
|
|
should be written as lists. Variables' and colors' names should be
|
|
quoted. See <https://wiki.hypr.land/Hypr-Ecosystem/hypridle/> for more examples.
|
|
'';
|
|
example = {
|
|
general = {
|
|
after_sleep_cmd = "hyprctl dispatch dpms on";
|
|
ignore_dbus_inhibit = false;
|
|
lock_cmd = "hyprlock";
|
|
};
|
|
|
|
listener = [
|
|
{
|
|
timeout = 900;
|
|
on-timeout = "hyprlock";
|
|
}
|
|
{
|
|
timeout = 1200;
|
|
on-timeout = "hyprctl dispatch dpms off";
|
|
on-resume = "hyprctl dispatch dpms on";
|
|
}
|
|
];
|
|
};
|
|
};
|
|
|
|
importantPrefixes = lib.mkOption {
|
|
type = with lib.types; listOf str;
|
|
default = [ "$" ];
|
|
example = [ "$" ];
|
|
description = ''
|
|
List of prefix of attributes to source at the top of the config.
|
|
'';
|
|
};
|
|
|
|
systemdTarget = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = config.wayland.systemd.target;
|
|
defaultText = lib.literalExpression "config.wayland.systemd.target";
|
|
example = "hyprland-session.target";
|
|
description = "Systemd target to bind to.";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
xdg.configFile."hypr/hypridle.conf" = lib.mkIf (cfg.settings != { }) {
|
|
text = lib.hm.generators.toHyprconf {
|
|
attrs = cfg.settings;
|
|
inherit (cfg) importantPrefixes;
|
|
};
|
|
};
|
|
|
|
systemd.user.services.hypridle = lib.mkIf (cfg.package != null) {
|
|
Install = {
|
|
WantedBy = [ cfg.systemdTarget ];
|
|
};
|
|
|
|
Unit = {
|
|
ConditionEnvironment = "WAYLAND_DISPLAY";
|
|
Description = "hypridle";
|
|
After = [ cfg.systemdTarget ];
|
|
PartOf = [ cfg.systemdTarget ];
|
|
X-Restart-Triggers = lib.mkIf (cfg.settings != { }) [
|
|
"${config.xdg.configFile."hypr/hypridle.conf".source}"
|
|
];
|
|
};
|
|
|
|
Service = {
|
|
ExecStart = "${lib.getExe cfg.package}";
|
|
Restart = "always";
|
|
RestartSec = "10";
|
|
};
|
|
};
|
|
};
|
|
}
|