Add wireless options
This commit is contained in:
parent
2999346274
commit
a4cd619f69
36
README.md
36
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 <<EOF
|
||||
uci -q batch << EOI
|
||||
set system.@system[0].hostname='testap'
|
||||
commit
|
||||
EOI
|
||||
EOF
|
||||
'';
|
||||
wireless.interfaces.ap0 = {
|
||||
device = "radio0";
|
||||
network = "lan";
|
||||
mode = "ap";
|
||||
ssid = "Test AP";
|
||||
};
|
||||
|
||||
})
|
||||
];
|
||||
|
@ -94,18 +88,12 @@ in sys.config.system.build.image
|
|||
|
||||
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 <<EOF
|
||||
uci -q batch << EOI
|
||||
set system.@system[0].hostname='testap'
|
||||
commit
|
||||
EOI
|
||||
EOF
|
||||
'';
|
||||
wireless.interfaces.ap0 = {
|
||||
device = "radio0";
|
||||
network = "lan";
|
||||
mode = "ap";
|
||||
ssid = "Test AP";
|
||||
};
|
||||
|
||||
})
|
||||
];
|
||||
|
|
21
example.nix
21
example.nix
|
@ -4,24 +4,19 @@
|
|||
build.profile = "avm_fritz7412";
|
||||
|
||||
system.settings = {
|
||||
hostname = "testap";
|
||||
description = "nix-openwrt-imagebuilder example";
|
||||
timezone = "CET-1CEST,M3.5.0,M10.5.0/3";
|
||||
};
|
||||
|
||||
packages.include = [ "tcpdump" "vxlan" "kmod-vxlan" ];
|
||||
|
||||
dropbear.settings = {
|
||||
PasswordAuth = false;
|
||||
dropbear.settings = { PasswordAuth = false; };
|
||||
|
||||
wireless.interfaces.ap0 = {
|
||||
device = "radio0";
|
||||
network = "lan";
|
||||
mode = "ap";
|
||||
ssid = "Test AP";
|
||||
};
|
||||
|
||||
files = pkgs.runCommandNoCC "image-files" { } ''
|
||||
mkdir -p $out/etc/uci-defaults
|
||||
cat > $out/etc/uci-defaults/99-custom <<EOF
|
||||
uci -q batch << EOI
|
||||
set system.@system[0].hostname='testap'
|
||||
commit
|
||||
EOI
|
||||
EOF
|
||||
'';
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
options = with lib; {
|
||||
|
||||
files = mkOption {
|
||||
type = types.path;
|
||||
type = with types; nullOr path;
|
||||
default = null;
|
||||
example = literalExample ''
|
||||
pkgs.runCommandNoCC "image-files" { } '''
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
let cfg = config.wireless;
|
||||
in {
|
||||
options.wireless = with lib; {
|
||||
|
||||
devices = mkOption {
|
||||
default = { };
|
||||
description = ''
|
||||
See <link xlink:href="https://openwrt.org/docs/guide-user/network/wifi/basic#wi-fi_devices"/>
|
||||
'';
|
||||
type = with types; attrsOf uciSection;
|
||||
example = {
|
||||
wl0 = {
|
||||
type = "broadcom";
|
||||
channel = 6;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
interfaces = mkOption {
|
||||
default = { };
|
||||
description = ''
|
||||
See <link xlink:href="https://openwrt.org/docs/guide-user/network/wifi/basic#wi-fi_interfaces"/>
|
||||
'';
|
||||
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));
|
||||
|
||||
}
|
|
@ -20,6 +20,7 @@ let
|
|||
./modules/services.nix
|
||||
./modules/system.nix
|
||||
./modules/uci.nix
|
||||
./modules/wireless.nix
|
||||
] ++ modules;
|
||||
};
|
||||
in { inherit (result) config options; }
|
||||
|
|
Loading…
Reference in New Issue