pkgs/openwrt: install vxlan if needed

This commit is contained in:
Astro 2022-09-14 17:47:09 +02:00
parent d95c54e3c2
commit 747a923774
1 changed files with 16 additions and 1 deletions

View File

@ -43,10 +43,18 @@ in rec {
buildImage = hostName: buildImage = hostName:
let 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 { matches = (openwrt-imagebuilder.lib.profiles {
inherit pkgs; inherit pkgs;
}).identifyProfiles model; }).identifyProfiles model;
fallbackProfile = fallbackProfile =
if model == "dir-615-d" if model == "dir-615-d"
then (openwrt-imagebuilder.lib.profiles { then (openwrt-imagebuilder.lib.profiles {
@ -67,6 +75,7 @@ in rec {
}; };
} }
else null; else null;
build = args: build = args:
openwrt-imagebuilder.lib.build (args // { openwrt-imagebuilder.lib.build (args // {
extraImageName = "zw-${hostName}"; extraImageName = "zw-${hostName}";
@ -84,6 +93,8 @@ in rec {
# wpa3 # wpa3
"-wpad-basic-wolfssl" "-wpad-mini" "-wpad-basic-wolfssl" "-wpad-mini"
"wpad-openssl" "wpad-openssl"
] ++ nixpkgs.lib.optionals hasVxlan [
"vxlan" "kmod-vxlan"
] ++ modelPackages.${model} or []; ] ++ modelPackages.${model} or [];
disabledServices = [ "dnsmasq" "uhttpd" ]; disabledServices = [ "dnsmasq" "uhttpd" ];
files = pkgs.runCommandNoCC "image-files" {} '' files = pkgs.runCommandNoCC "image-files" {} ''
@ -93,14 +104,18 @@ in rec {
EOF EOF
''; '';
}); });
in in
if matches == [] && fallbackProfile != null if matches == [] && fallbackProfile != null
then build fallbackProfile then build fallbackProfile
else if matches == [] else if matches == []
then builtins.trace "${hostName} (${model}) not supported by OpenWRT" then builtins.trace "${hostName} (${model}) not supported by OpenWRT"
null null
else if builtins.length matches == 1 else if builtins.length matches == 1
then build (builtins.elemAt matches 0) then build (builtins.elemAt matches 0)
else builtins.trace "${hostName} (${model}) has multiple models!" ( else builtins.trace "${hostName} (${model}) has multiple models!" (
build (builtins.elemAt matches 0) build (builtins.elemAt matches 0)
); );