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" ];
|
services.disabled = [ "dnsmasq" ];
|
||||||
|
|
||||||
# include files in the images.
|
wireless.interfaces.ap0 = {
|
||||||
# to set UCI configuration, create a uci-defauts scripts as per
|
device = "radio0";
|
||||||
# official OpenWRT ImageBuilder recommendation.
|
network = "lan";
|
||||||
files = pkgs.runCommandNoCC "image-files" { } ''
|
mode = "ap";
|
||||||
mkdir -p $out/etc/uci-defaults
|
ssid = "Test AP";
|
||||||
cat > $out/etc/uci-defaults/99-custom <<EOF
|
};
|
||||||
uci -q batch << EOI
|
|
||||||
set system.@system[0].hostname='testap'
|
|
||||||
commit
|
|
||||||
EOI
|
|
||||||
EOF
|
|
||||||
'';
|
|
||||||
|
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
@ -94,18 +88,12 @@ in sys.config.system.build.image
|
||||||
|
|
||||||
services.disabled = [ "dnsmasq" ];
|
services.disabled = [ "dnsmasq" ];
|
||||||
|
|
||||||
# include files in the images.
|
wireless.interfaces.ap0 = {
|
||||||
# to set UCI configuration, create a uci-defauts scripts as per
|
device = "radio0";
|
||||||
# official OpenWRT ImageBuilder recommendation.
|
network = "lan";
|
||||||
files = pkgs.runCommandNoCC "image-files" { } ''
|
mode = "ap";
|
||||||
mkdir -p $out/etc/uci-defaults
|
ssid = "Test AP";
|
||||||
cat > $out/etc/uci-defaults/99-custom <<EOF
|
};
|
||||||
uci -q batch << EOI
|
|
||||||
set system.@system[0].hostname='testap'
|
|
||||||
commit
|
|
||||||
EOI
|
|
||||||
EOF
|
|
||||||
'';
|
|
||||||
|
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
21
example.nix
21
example.nix
|
@ -4,24 +4,19 @@
|
||||||
build.profile = "avm_fritz7412";
|
build.profile = "avm_fritz7412";
|
||||||
|
|
||||||
system.settings = {
|
system.settings = {
|
||||||
|
hostname = "testap";
|
||||||
description = "nix-openwrt-imagebuilder example";
|
description = "nix-openwrt-imagebuilder example";
|
||||||
timezone = "CET-1CEST,M3.5.0,M10.5.0/3";
|
timezone = "CET-1CEST,M3.5.0,M10.5.0/3";
|
||||||
};
|
};
|
||||||
|
|
||||||
packages.include = [ "tcpdump" "vxlan" "kmod-vxlan" ];
|
packages.include = [ "tcpdump" "vxlan" "kmod-vxlan" ];
|
||||||
|
|
||||||
dropbear.settings = {
|
dropbear.settings = { PasswordAuth = false; };
|
||||||
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; {
|
options = with lib; {
|
||||||
|
|
||||||
files = mkOption {
|
files = mkOption {
|
||||||
type = types.path;
|
type = with types; nullOr path;
|
||||||
default = null;
|
default = null;
|
||||||
example = literalExample ''
|
example = literalExample ''
|
||||||
pkgs.runCommandNoCC "image-files" { } '''
|
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/services.nix
|
||||||
./modules/system.nix
|
./modules/system.nix
|
||||||
./modules/uci.nix
|
./modules/uci.nix
|
||||||
|
./modules/wireless.nix
|
||||||
] ++ modules;
|
] ++ modules;
|
||||||
};
|
};
|
||||||
in { inherit (result) config options; }
|
in { inherit (result) config options; }
|
||||||
|
|
Loading…
Reference in New Issue