forked from DGNum/liminix
WIP push to see what passes
This commit is contained in:
parent
259f5c767b
commit
adc198b3af
7 changed files with 100 additions and 57 deletions
|
@ -38,7 +38,7 @@
|
||||||
supported by the ath10k driver.
|
supported by the ath10k driver.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
module = {pkgs, ... }:
|
module = {pkgs, config, ... }:
|
||||||
let
|
let
|
||||||
openwrt = pkgs.pkgsBuildBuild.fetchFromGitHub {
|
openwrt = pkgs.pkgsBuildBuild.fetchFromGitHub {
|
||||||
name = "openwrt-source";
|
name = "openwrt-source";
|
||||||
|
@ -64,6 +64,10 @@
|
||||||
cp $blobdir/board.bin $out/ath10k/QCA9887/hw1.0/
|
cp $blobdir/board.bin $out/ath10k/QCA9887/hw1.0/
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
mac80211 = pkgs.mac80211.override {
|
||||||
|
drivers = ["ath9k" "ath10k_pci"];
|
||||||
|
klibBuild = config.outputs.kernel.modulesupport;
|
||||||
|
};
|
||||||
ath10k_cal_data =
|
ath10k_cal_data =
|
||||||
let
|
let
|
||||||
offset = 1024 * 20; # 0x5000
|
offset = 1024 * 20; # 0x5000
|
||||||
|
@ -81,12 +85,25 @@
|
||||||
down = "true";
|
down = "true";
|
||||||
};
|
};
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
|
inherit (pkgs.liminix.networking) interface;
|
||||||
in {
|
in {
|
||||||
device = {
|
device = {
|
||||||
defaultOutput = "tftproot";
|
defaultOutput = "tftproot";
|
||||||
loadAddress = "0x80060000";
|
loadAddress = "0x80060000";
|
||||||
entryPoint = "0x80060000";
|
entryPoint = "0x80060000";
|
||||||
radios = ["ath9k" "ath10k_pci"];
|
networkInterfaces = {
|
||||||
|
lan = interface { device = "eth0"; };
|
||||||
|
wan = interface { device = "eth1"; };
|
||||||
|
|
||||||
|
wlan_24 = interface {
|
||||||
|
device = "wlan0";
|
||||||
|
dependencies = [ mac80211 ];
|
||||||
|
};
|
||||||
|
wlan_5 = interface {
|
||||||
|
device = "wlan1";
|
||||||
|
dependencies = [ mac80211 ath10k_cal_data ];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
filesystem = dir {
|
filesystem = dir {
|
||||||
lib = dir {
|
lib = dir {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# This "device" generates images that can be used with the QEMU
|
# This "device" generates images that can be used with the QEMU
|
||||||
# emulator. The default output is a directory containing separate
|
# emulator. The default output is a directory containing separate
|
||||||
# kernel (uncompressed vmlinux) and initrd (squashfs) images
|
# kernel (uncompressed vmlinux) and initrd (squashfs) images
|
||||||
|
|
||||||
{
|
{
|
||||||
system = {
|
system = {
|
||||||
crossSystem = {
|
crossSystem = {
|
||||||
|
@ -13,7 +12,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
module = {pkgs, ... }: {
|
module = {pkgs, config, ... }: {
|
||||||
kernel = {
|
kernel = {
|
||||||
src = pkgs.pkgsBuildBuild.fetchurl {
|
src = pkgs.pkgsBuildBuild.fetchurl {
|
||||||
name = "linux.tar.gz";
|
name = "linux.tar.gz";
|
||||||
|
@ -41,9 +40,25 @@
|
||||||
SERIAL_8250_CONSOLE= "y";
|
SERIAL_8250_CONSOLE= "y";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
device = {
|
device =
|
||||||
defaultOutput = "vmroot";
|
let
|
||||||
radios = ["mac80211_hwsim"];
|
mac80211 = pkgs.mac80211.override {
|
||||||
|
drivers = ["mac80211_hwsim"];
|
||||||
|
klibBuild = config.outputs.kernel.modulesupport;
|
||||||
};
|
};
|
||||||
|
inherit (pkgs.liminix.networking) interface;
|
||||||
|
in {
|
||||||
|
defaultOutput = "vmroot";
|
||||||
|
networkInterfaces = {
|
||||||
|
lan = interface { device = "eth0"; };
|
||||||
|
wan = interface { device = "eth1"; };
|
||||||
|
|
||||||
|
wlan_24 = interface {
|
||||||
|
device = "wlan0";
|
||||||
|
dependencies = [ mac80211 ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,9 @@ in {
|
||||||
default = [];
|
default = [];
|
||||||
example = ["ath9k" "ath10k"];
|
example = ["ath9k" "ath10k"];
|
||||||
};
|
};
|
||||||
|
networkInterfaces = mkOption {
|
||||||
|
type = types.attrsOf types.anything;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
|
|
|
@ -3,15 +3,8 @@ let
|
||||||
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
|
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
inherit (pkgs) busybox;
|
inherit (pkgs) busybox;
|
||||||
mac80211 = pkgs.mac80211.override {
|
|
||||||
drivers = config.device.radios;
|
|
||||||
klibBuild = config.outputs.kernel.modulesupport;
|
|
||||||
};
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
config = {
|
config = {
|
||||||
services.wlan_module = mac80211;
|
|
||||||
|
|
||||||
kernel = rec {
|
kernel = rec {
|
||||||
config = {
|
config = {
|
||||||
# Most of this is necessary infra to allow wireless stack/
|
# Most of this is necessary infra to allow wireless stack/
|
||||||
|
|
|
@ -8,7 +8,7 @@ let
|
||||||
inherit (liminix.services) oneshot longrun;
|
inherit (liminix.services) oneshot longrun;
|
||||||
inherit (lib) concatStringsSep optional;
|
inherit (lib) concatStringsSep optional;
|
||||||
in {
|
in {
|
||||||
interface = { type, device, primary ? null, dependencies ? [] } @ args:
|
interface = { type ? "hardware", device, primary ? null, dependencies ? [] } @ args:
|
||||||
let ups =
|
let ups =
|
||||||
[]
|
[]
|
||||||
++ optional (type == "bridge")
|
++ optional (type == "bridge")
|
||||||
|
@ -25,10 +25,10 @@ in {
|
||||||
} // {
|
} // {
|
||||||
inherit device;
|
inherit device;
|
||||||
};
|
};
|
||||||
address = interface: { family, prefixLength, address } @ args:
|
address = interface: { family, dependencies ? [], prefixLength, address } @ args:
|
||||||
let inherit (builtins) toString;
|
let inherit (builtins) toString;
|
||||||
in oneshot {
|
in oneshot {
|
||||||
dependencies = [ interface ];
|
dependencies = [ interface ] ++ dependencies;
|
||||||
name = "${interface.device}.addr.${address}";
|
name = "${interface.device}.addr.${address}";
|
||||||
up = "ip address add ${address}/${toString prefixLength} dev ${interface.device} ";
|
up = "ip address add ${address}/${toString prefixLength} dev ${interface.device} ";
|
||||||
down = "ip address del ${address}/${toString prefixLength} dev ${interface.device} ";
|
down = "ip address del ${address}/${toString prefixLength} dev ${interface.device} ";
|
||||||
|
|
89
rotuer.nix
89
rotuer.nix
|
@ -11,7 +11,7 @@ let
|
||||||
secrets = import ./rotuer-secrets.nix;
|
secrets = import ./rotuer-secrets.nix;
|
||||||
inherit (pkgs.liminix.networking)
|
inherit (pkgs.liminix.networking)
|
||||||
address
|
address
|
||||||
bridge
|
# bridge
|
||||||
dnsmasq
|
dnsmasq
|
||||||
hostapd
|
hostapd
|
||||||
interface
|
interface
|
||||||
|
@ -83,28 +83,7 @@ in rec {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.lan =
|
services.hostap = hostapd (config.device.networkInterfaces.wlan_24) {
|
||||||
let iface = interface {
|
|
||||||
type = "bridge";
|
|
||||||
device = "lan";
|
|
||||||
};
|
|
||||||
in address iface {
|
|
||||||
family = "inet4"; address ="10.8.0.1"; prefixLength = 16;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.wireless = interface {
|
|
||||||
type = "hardware";
|
|
||||||
device = "wlan0";
|
|
||||||
dependencies = [ config.services.wlan_module ];
|
|
||||||
};
|
|
||||||
|
|
||||||
services.wired = interface {
|
|
||||||
type = "hardware";
|
|
||||||
device = "eth0";
|
|
||||||
primary = services.lan;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.hostap = hostapd (services.wireless) {
|
|
||||||
params = {
|
params = {
|
||||||
ssid = "liminix";
|
ssid = "liminix";
|
||||||
country_code = "GB";
|
country_code = "GB";
|
||||||
|
@ -121,16 +100,54 @@ in rec {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.bridgewlan =
|
services.hostap5 = hostapd (config.device.networkInterfaces.wlan_5) {
|
||||||
let dev = services.wireless.device;
|
params = rec {
|
||||||
in oneshot {
|
ssid = "liminix_5";
|
||||||
name = "add-wlan2-to-bridge";
|
country_code = "GB";
|
||||||
up = "${ifwait}/bin/ifwait -v ${dev} running && ip link set dev ${dev} master ${services.lan.device}";
|
hw_mode="a";
|
||||||
down = "ip link set dev ${dev} nomaster";
|
channel = 36;
|
||||||
dependencies = [ services.wireless ];
|
ht_capab = "[HT40+]";
|
||||||
|
vht_oper_chwidth = 1;
|
||||||
|
vht_oper_centr_freq_seg0_idx = channel + 6;
|
||||||
|
ieee80211ac = 1;
|
||||||
|
|
||||||
|
wmm_enabled = 1;
|
||||||
|
inherit (secrets) wpa_passphrase;
|
||||||
|
auth_algs = 1; # 1=wpa2, 2=wep, 3=both
|
||||||
|
wpa = 2; # 1=wpa, 2=wpa2, 3=both
|
||||||
|
wpa_key_mgmt = "WPA-PSK";
|
||||||
|
wpa_pairwise = "TKIP CCMP"; # auth for wpa (may not need this?)
|
||||||
|
rsn_pairwise = "CCMP"; # auth for wpa2
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.int =
|
||||||
|
let iface = interface {
|
||||||
|
type = "bridge";
|
||||||
|
device = "int";
|
||||||
|
};
|
||||||
|
in address iface {
|
||||||
|
family = "inet4"; address ="10.8.0.1"; prefixLength = 16;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.bridge =
|
||||||
|
let
|
||||||
|
primary = services.int;
|
||||||
|
addif = dev: oneshot {
|
||||||
|
name = "add-${dev.device}-to-bridge";
|
||||||
|
up = "${ifwait}/bin/ifwait -v ${dev.device} running && ip link set dev ${dev.device} master ${primary.device}";
|
||||||
|
down = "ip link set dev ${dev} nomaster";
|
||||||
|
dependencies = [ primary dev ];
|
||||||
|
};
|
||||||
|
in bundle {
|
||||||
|
name = "bridge-members";
|
||||||
|
contents = map addif [
|
||||||
|
config.device.networkInterfaces.wlan_24
|
||||||
|
config.device.networkInterfaces.lan
|
||||||
|
config.device.networkInterfaces.wlan_5
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
users.dnsmasq = {
|
users.dnsmasq = {
|
||||||
uid = 51; gid= 51; gecos = "DNS/DHCP service user";
|
uid = 51; gid= 51; gecos = "DNS/DHCP service user";
|
||||||
dir = "/run/dnsmasq";
|
dir = "/run/dnsmasq";
|
||||||
|
@ -144,13 +161,13 @@ in rec {
|
||||||
services.dns =
|
services.dns =
|
||||||
dnsmasq {
|
dnsmasq {
|
||||||
resolvconf = services.resolvconf;
|
resolvconf = services.resolvconf;
|
||||||
interface = services.lan;
|
interface = services.int;
|
||||||
ranges = ["10.8.0.10,10.8.0.240"];
|
ranges = ["10.8.0.10,10.8.0.240"];
|
||||||
domain = "fake.liminix.org";
|
domain = "fake.liminix.org";
|
||||||
};
|
};
|
||||||
|
|
||||||
services.wan =
|
services.wan =
|
||||||
let iface = interface { type = "hardware"; device = "eth1"; };
|
let iface = config.device.networkInterfaces.wan;
|
||||||
in pppoe iface {
|
in pppoe iface {
|
||||||
ppp-options = [
|
ppp-options = [
|
||||||
"debug" "+ipv6" "noauth"
|
"debug" "+ipv6" "noauth"
|
||||||
|
@ -196,14 +213,14 @@ in rec {
|
||||||
name = "default";
|
name = "default";
|
||||||
contents = with services; [
|
contents = with services; [
|
||||||
loopback
|
loopback
|
||||||
wired
|
config.device.networkInterfaces.lan
|
||||||
wireless
|
int
|
||||||
lan
|
bridge
|
||||||
hostap
|
hostap
|
||||||
|
hostap5
|
||||||
defaultroute4
|
defaultroute4
|
||||||
packet_forwarding
|
packet_forwarding
|
||||||
dns
|
dns
|
||||||
bridgewlan
|
|
||||||
resolvconf
|
resolvconf
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,8 +15,7 @@ in rec {
|
||||||
|
|
||||||
imports = [ ../../modules/wlan.nix ];
|
imports = [ ../../modules/wlan.nix ];
|
||||||
|
|
||||||
|
services.wlan = config.device.networkInterfaces.wlan_24;
|
||||||
services.wlan = interface { type = "hardware"; device = "wlan0"; };
|
|
||||||
|
|
||||||
services.hostap = hostapd (services.wlan) {
|
services.hostap = hostapd (services.wlan) {
|
||||||
params = {
|
params = {
|
||||||
|
@ -40,7 +39,6 @@ in rec {
|
||||||
contents = with config.services; [
|
contents = with config.services; [
|
||||||
loopback
|
loopback
|
||||||
hostap
|
hostap
|
||||||
wlan_module
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
defaultProfile.packages = with pkgs; [ tcpdump ] ;
|
defaultProfile.packages = with pkgs; [ tcpdump ] ;
|
||||||
|
|
Loading…
Reference in a new issue