liminix/modules/vlan/service.nix

22 lines
573 B
Nix
Raw Normal View History

{
liminix
, lib
}:
{ ifname, primary, vid, untagged } :
let
inherit (lib) optionalString;
inherit (liminix.services) oneshot;
in oneshot rec {
name = "${ifname}.link";
up = ''
ip link add link $(output ${primary} ifname) name ${ifname} type vlan id ${vid}
${optionalString untagged.egress "bridge vlan add dev ${ifname} vid ${toString untagged.vid} pvid untagged master"}
${liminix.networking.ifup name ifname}
2023-09-15 22:45:00 +02:00
(in_outputs ${name}
echo ${ifname} > ifname
)
'';
down = "ip link set down dev ${ifname}";
dependencies = [ primary ];
}