pkgs/openwrt-images: add support for legacy devices

This commit is contained in:
Astro 2022-04-30 01:31:56 +02:00
parent d54bb4f871
commit 7a00fd74cf
3 changed files with 33 additions and 9 deletions

View File

@ -810,7 +810,7 @@
};
};
location = "B 4.08";
model = "tl-wr1043n-v5";
model = "tplink_tl-wr1043n-v5";
role = "ap";
wifi = {
"platform/qca956x_wmac" = {

View File

@ -68,11 +68,11 @@
"openwrt": "openwrt_2"
},
"locked": {
"lastModified": 1651184984,
"narHash": "sha256-i6yHFo0isdKtG4hsMwo6rhoqJ/zvnDNX0d+W2ola1vs=",
"lastModified": 1651275086,
"narHash": "sha256-HM0xBxcg7V4YXwXs//I1GJQJrIQ1jHMmY3zsYPsgRBY=",
"owner": "astro",
"repo": "nix-openwrt-imagebuilder",
"rev": "2087eb5f0cd68e15284550124b905105e9ad2ef5",
"rev": "34afaff593f10de376e50f2e02f61cb2d93e648e",
"type": "github"
},
"original": {

View File

@ -98,11 +98,35 @@ let
in
builtins.foldl' (images: hostName:
let
hostConfig = config.site.hosts.${hostName};
matches = profiles.identifyProfiles hostConfig.model;
inherit (config.site.hosts.${hostName}) model;
matches = profiles.identifyProfiles model;
fallbackProfile =
if model == "dir-615-d"
then (openwrt-imagebuilder.lib.profiles {
inherit pkgs;
release = "19.07.10";
}).identifyProfile model
else if builtins.match "tl-wr.*" model != null
then {
release = "18.06.9";
packagesArch = "mips_24kc";
target = "ar71xx";
variant = "tiny";
profile = model;
sha256 = "109a2557gwmgib7r500qn9ygd8j4r4cv5jl5rpn9vczsm4ilkc1z";
feedsSha256 = {
base = "0xklqsk6d5d6bai0ry2hzfjr4sycf6241ihv8v1lmmf9r7d47cr1";
packages = "05g048saibh304ndnlczyq92b1c67c3cqvbhdamw1xqbsp6jzifp";
};
}
else null;
in
if matches == []
then builtins.trace "${hostName} (${hostConfig.model}) not supported by OpenWRT"
if matches == [] && fallbackProfile != null
then images // {
"${hostName}-image" = build fallbackProfile;
}
else if matches == []
then builtins.trace "${hostName} (${model}) not supported by OpenWRT"
images
else if builtins.length matches == 1
then
@ -111,7 +135,7 @@ let
builtins.elemAt matches 0
);
}
else builtins.trace "${hostName} (${hostConfig.model}) has multiple models!"
else builtins.trace "${hostName} (${model}) has multiple models!"
images // {
"${hostName}-image" = build (
builtins.elemAt matches 0