2024-01-09 19:21:24 +01:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit
|
|
|
|
(lib)
|
|
|
|
mkEnableOption
|
|
|
|
mkOption
|
|
|
|
types
|
|
|
|
mkIf
|
|
|
|
getExe
|
|
|
|
;
|
|
|
|
cfg = config.services.ifstate;
|
|
|
|
format = pkgs.formats.json {};
|
|
|
|
in {
|
|
|
|
options.services.ifstate = {
|
|
|
|
enable =
|
|
|
|
mkEnableOption "Enable ifstate service";
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.ifstate;
|
|
|
|
description = ''
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = format.type;
|
|
|
|
default = {};
|
|
|
|
description = ''
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.ifstate = {
|
|
|
|
description = "ifstate service";
|
2024-08-14 15:57:02 +02:00
|
|
|
wantedBy = ["network.target"];
|
|
|
|
before = ["network-pre.target" "dhcpcd.service"];
|
2024-01-09 19:21:24 +01:00
|
|
|
|
2024-10-27 12:43:39 +01:00
|
|
|
reloadIfChanged = true;
|
2024-01-09 19:21:24 +01:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
2024-10-27 12:43:39 +01:00
|
|
|
ExecStart = "${getExe cfg.package} -vc ${format.generate "ifstate.json" cfg.settings} apply";
|
|
|
|
ExecReload = "${getExe cfg.package} -vc ${format.generate "ifstate.json" cfg.settings} apply";
|
2024-01-09 19:21:24 +01:00
|
|
|
RemainAfterExit = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|