From 747a923774592a98b04be6a6c37893286b2073dc Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 14 Sep 2022 17:47:09 +0200 Subject: [PATCH] pkgs/openwrt: install vxlan if needed --- nix/pkgs/openwrt/default.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/nix/pkgs/openwrt/default.nix b/nix/pkgs/openwrt/default.nix index 45ac716..1a06dc6 100644 --- a/nix/pkgs/openwrt/default.nix +++ b/nix/pkgs/openwrt/default.nix @@ -43,10 +43,18 @@ in rec { buildImage = hostName: let - inherit (config.site.hosts.${hostName}) model; + hostConfig = config.site.hosts.${hostName}; + + hasVxlan = builtins.any ({ type, ... }: + type == "vxlan" + ) (builtins.attrValues hostConfig.interfaces); + + inherit (hostConfig) model; + matches = (openwrt-imagebuilder.lib.profiles { inherit pkgs; }).identifyProfiles model; + fallbackProfile = if model == "dir-615-d" then (openwrt-imagebuilder.lib.profiles { @@ -67,6 +75,7 @@ in rec { }; } else null; + build = args: openwrt-imagebuilder.lib.build (args // { extraImageName = "zw-${hostName}"; @@ -84,6 +93,8 @@ in rec { # wpa3 "-wpad-basic-wolfssl" "-wpad-mini" "wpad-openssl" + ] ++ nixpkgs.lib.optionals hasVxlan [ + "vxlan" "kmod-vxlan" ] ++ modelPackages.${model} or []; disabledServices = [ "dnsmasq" "uhttpd" ]; files = pkgs.runCommandNoCC "image-files" {} '' @@ -93,14 +104,18 @@ in rec { EOF ''; }); + in if matches == [] && fallbackProfile != null then build fallbackProfile + else if matches == [] then builtins.trace "${hostName} (${model}) not supported by OpenWRT" null + else if builtins.length matches == 1 then build (builtins.elemAt matches 0) + else builtins.trace "${hostName} (${model}) has multiple models!" ( build (builtins.elemAt matches 0) );