diff --git a/README.md b/README.md index c3572b2..18937fb 100644 --- a/README.md +++ b/README.md @@ -47,18 +47,12 @@ let services.disabled = [ "dnsmasq" ]; - # include files in the images. - # to set UCI configuration, create a uci-defauts scripts as per - # official OpenWRT ImageBuilder recommendation. - files = pkgs.runCommandNoCC "image-files" { } '' - mkdir -p $out/etc/uci-defaults - cat > $out/etc/uci-defaults/99-custom < $out/etc/uci-defaults/99-custom < $out/etc/uci-defaults/99-custom < + ''; + type = with types; attrsOf uciSection; + example = { + wl0 = { + type = "broadcom"; + channel = 6; + }; + }; + }; + + interfaces = mkOption { + default = { }; + description = '' + See + ''; + type = with types; attrsOf uciSection; + example = { + ap0 = { + device = "wl0"; + network = "lan"; + mode = "ap"; + ssid = "MyWifiAP"; + encryption = "psk2"; + key = "secret passphrase"; + }; + }; + }; + + }; + + config.uci.batch = let + toUci' = type: + (lib.attrsets.mapAttrsToList (section: settings: + lib.toUciBatch { + config = "wireless"; + inherit section type; + } settings)); + in lib.strings.concatStringsSep "\n" + ((toUci' "wifi-device" cfg.devices) ++ (toUci' "wifi-iface" cfg.interfaces)); + +} diff --git a/lib/openwrt-system.nix b/lib/openwrt-system.nix index 19a8676..3fc1b4f 100644 --- a/lib/openwrt-system.nix +++ b/lib/openwrt-system.nix @@ -20,6 +20,7 @@ let ./modules/services.nix ./modules/system.nix ./modules/uci.nix + ./modules/wireless.nix ] ++ modules; }; in { inherit (result) config options; }