mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-26 01:56:13 +01:00
6df907e0c3
Signed-off-by: magic_rb <magic_rb@redalder.org>
54 lines
1 KiB
Nix
54 lines
1 KiB
Nix
{
|
|
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";
|
|
wantedBy = ["network.target"];
|
|
before = ["network-pre.target" "dhcpcd.service"];
|
|
|
|
reloadIfChanged = true;
|
|
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
ExecStart = "${getExe cfg.package} -vc ${format.generate "ifstate.json" cfg.settings} apply";
|
|
ExecReload = "${getExe cfg.package} -vc ${format.generate "ifstate.json" cfg.settings} apply";
|
|
RemainAfterExit = true;
|
|
};
|
|
};
|
|
};
|
|
}
|