diff --git a/example.nix b/example.nix index 248ebd6..c9d8aa2 100644 --- a/example.nix +++ b/example.nix @@ -1,34 +1,22 @@ { pkgs ? import {} }: -import ./builder.nix { - inherit pkgs; - target = "ath79"; - profile = "ubnt_unifiac-lite"; - packages = [ - "tcpdump" - "vxlan" "kmod-vxlan" - "-ath10k-firmware-qca988x-ct" "ath10k-firmware-qca988x" - "-kmod-ath10k-ct" "kmod-ath10k" - ]; - files = pkgs.runCommandNoCC "image-files" {} '' - mkdir -p $out/etc/uci-defaults - cat > $out/etc/uci-defaults/99-custom < $out/etc/uci-defaults/99-custom < {} +# OpenWRT release +, release ? "21.02.3" +}: +with pkgs; +let + hashes = import ./hashes/${release}.nix; +in rec { + allProfiles = + builtins.mapAttrs (target: variants: + lib.filterAttrs (_: profiles: + profiles != null + ) ( + builtins.mapAttrs (variant: h: + (import ./files.nix { + inherit pkgs release target variant; + inherit (h) sha256 feedsSha256; + }).profiles + ) variants + ) + ) hashes; + + # filters hardware profiles from all boards.json files + identifyProfile = profile: + builtins.concatMap (target: + map (variant: { + # match return value + inherit pkgs release target variant profile; + }) ( + builtins.filter (variant: + allProfiles.${target}.${variant}.profiles ? ${profile} + ) (builtins.attrNames allProfiles.${target}) + ) + ) (builtins.attrNames allProfiles); +}