create outputs for network interface

This commit is contained in:
Daniel Barlow 2023-08-27 22:34:00 +01:00
parent 485ecc03b0
commit 6da0e67621

View file

@ -9,7 +9,8 @@ let
inherit (lib) concatStringsSep optional; inherit (lib) concatStringsSep optional;
in { in {
interface = { type ? "hardware", device, link ? null, primary ? null, id ? null, dependencies ? [] } @ args: interface = { type ? "hardware", device, link ? null, primary ? null, id ? null, dependencies ? [] } @ args:
let ups = let name = "${device}.link";
ups =
[] []
++ optional (type == "bridge") ++ optional (type == "bridge")
"ip link add name ${device} type bridge" "ip link add name ${device} type bridge"
@ -20,7 +21,7 @@ in {
++ optional (primary != null) ++ optional (primary != null)
"ip link set dev ${device} master ${primary.device}"; "ip link set dev ${device} master ${primary.device}";
in oneshot { in oneshot {
name = "${device}.link"; inherit name;
up = lib.concatStringsSep "\n" ups; up = lib.concatStringsSep "\n" ups;
down = "ip link set down dev ${device}"; down = "ip link set down dev ${device}";
dependencies = dependencies ++ lib.optional (primary != null) primary; dependencies = dependencies ++ lib.optional (primary != null) primary;