wlsunset: add assertion and correct option types

This commit is contained in:
daru 2024-04-30 18:08:08 +02:00
parent 11328b52fa
commit 35877def72
1 changed files with 19 additions and 6 deletions

View File

@ -5,7 +5,7 @@
...
}:
with lib; let
cfg = config.services.wlsunset-test;
cfg = config.services.wlsunset;
in {
meta.maintainers = [hm.maintainers.matrss];
@ -22,9 +22,9 @@ in {
};
latitude = mkOption {
type = with types; nullOr (either float (either str int));
type = with types; nullOr (either float int);
default = null;
example = "-74.3";
example = -74.3;
description = ''
Your current latitude, between `-90.0` and
`90.0`.
@ -32,9 +32,9 @@ in {
};
longitude = mkOption {
type = with types; nullOr (either float (either str int));
type = with types; nullOr (either float int);
default = null;
example = "12.5";
example = 12.5;
description = ''
Your current longitude, between `-180.0` and
`180.0`.
@ -62,8 +62,9 @@ in {
};
gamma = mkOption {
type = with types; either float (either str int);
type = with types; either float int;
default = 1.0;
example = 0.6;
description = ''
Gamma value to use.
'';
@ -108,6 +109,18 @@ in {
assertions = [
(lib.hm.assertions.assertPlatform "services.wlsunset" pkgs
lib.platforms.linux)
{
assertion = (cfg.sunrise != null || cfg.sunset != null) != (cfg.latitude != null || cfg.longitude != null);
message = "Either `sunrise` and `sunset` together or `longitude` and `latitude` together must be set for wlsunset";
}
{
assertion = (cfg.sunrise != null) == (cfg.sunset != null);
message = "Both `sunset` and `sunrise` together must be set for wlsunset";
}
{
assertion = (cfg.latitude != null) == (cfg.longitude != null);
message = "Both `latitude and `longitude` together must be set for wlsunset";
}
];
systemd.user.services.wlsunset = {