2020-11-28 00:47:35 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let cfg = config.services.wlsunset;
|
|
|
|
|
|
|
|
in {
|
2021-12-25 18:43:41 +00:00
|
|
|
meta.maintainers = [ hm.maintainers.matrss ];
|
2020-11-28 00:47:35 +00:00
|
|
|
|
|
|
|
options.services.wlsunset = {
|
2023-07-01 23:45:18 +00:00
|
|
|
enable = mkEnableOption "wlsunset";
|
2020-11-28 00:47:35 +00:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.wlsunset;
|
|
|
|
defaultText = "pkgs.wlsunset";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2020-11-28 00:47:35 +00:00
|
|
|
wlsunset derivation to use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
latitude = mkOption {
|
|
|
|
type = types.str;
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2023-06-30 23:30:13 +00:00
|
|
|
Your current latitude, between `-90.0` and
|
|
|
|
`90.0`.
|
2020-11-28 00:47:35 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
longitude = mkOption {
|
|
|
|
type = types.str;
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2023-06-30 23:30:13 +00:00
|
|
|
Your current longitude, between `-180.0` and
|
|
|
|
`180.0`.
|
2020-11-28 00:47:35 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
temperature = {
|
|
|
|
day = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 6500;
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2020-11-28 00:47:35 +00:00
|
|
|
Colour temperature to use during the day, in Kelvin (K).
|
2023-06-30 23:30:13 +00:00
|
|
|
This value must be greater than `temperature.night`.
|
2020-11-28 00:47:35 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
night = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 4000;
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2020-11-28 00:47:35 +00:00
|
|
|
Colour temperature to use during the night, in Kelvin (K).
|
2023-06-30 23:30:13 +00:00
|
|
|
This value must be smaller than `temperature.day`.
|
2020-11-28 00:47:35 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
gamma = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "1.0";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2020-11-28 00:47:35 +00:00
|
|
|
Gamma value to use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
systemdTarget = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "graphical-session.target";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2020-11-28 00:47:35 +00:00
|
|
|
Systemd target to bind to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-07-07 21:24:27 +00:00
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "services.wlsunset" pkgs
|
|
|
|
lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
2020-11-28 00:47:35 +00:00
|
|
|
systemd.user.services.wlsunset = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Day/night gamma adjustments for Wayland compositors.";
|
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
ExecStart = let
|
|
|
|
args = [
|
|
|
|
"-l ${cfg.latitude}"
|
|
|
|
"-L ${cfg.longitude}"
|
|
|
|
"-t ${toString cfg.temperature.night}"
|
|
|
|
"-T ${toString cfg.temperature.day}"
|
|
|
|
"-g ${cfg.gamma}"
|
|
|
|
];
|
|
|
|
in "${cfg.package}/bin/wlsunset ${concatStringsSep " " args}";
|
|
|
|
};
|
|
|
|
|
|
|
|
Install = { WantedBy = [ cfg.systemdTarget ]; };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|