2023-02-26 00:12:55 +01:00
|
|
|
# This is not part of Liminix per se. This is my "scratchpad"
|
|
|
|
# configuration for the device I'm testing with.
|
|
|
|
#
|
|
|
|
# Parts of it do do things that Liminix eventually needs to do, but
|
|
|
|
# don't look in here for solutions - just for identifying the
|
|
|
|
# problems.
|
|
|
|
|
|
|
|
|
|
|
|
{ config, pkgs, lib, ... } :
|
|
|
|
let
|
2024-02-11 10:10:03 +01:00
|
|
|
secrets = {
|
|
|
|
domainName = "fake.liminix.org";
|
|
|
|
firewallRules = {};
|
|
|
|
} // (import ./rotuer-secrets.nix);
|
2023-09-25 00:29:30 +02:00
|
|
|
inherit (pkgs.liminix.services) oneshot longrun bundle;
|
2023-09-04 23:05:42 +02:00
|
|
|
inherit (pkgs) serviceFns;
|
2023-07-20 12:28:45 +02:00
|
|
|
svc = config.system.service;
|
2023-07-23 00:37:01 +02:00
|
|
|
wirelessConfig = {
|
|
|
|
country_code = "GB";
|
|
|
|
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
|
|
|
|
wmm_enabled = 1;
|
|
|
|
};
|
|
|
|
|
2023-02-26 00:12:55 +01:00
|
|
|
in rec {
|
|
|
|
boot = {
|
|
|
|
tftp = {
|
2023-04-24 00:29:53 +02:00
|
|
|
freeSpaceBytes = 3 * 1024 * 1024;
|
2023-02-26 00:12:55 +01:00
|
|
|
serverip = "10.0.0.1";
|
|
|
|
ipaddr = "10.0.0.8";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
imports = [
|
2023-04-23 13:58:51 +02:00
|
|
|
../modules/wlan.nix
|
2023-08-28 00:45:27 +02:00
|
|
|
../modules/network
|
2023-07-14 22:08:33 +02:00
|
|
|
../modules/ppp
|
2023-07-14 23:53:25 +02:00
|
|
|
../modules/dnsmasq
|
2023-09-25 00:29:30 +02:00
|
|
|
../modules/dhcp6c
|
2023-07-16 17:55:50 +02:00
|
|
|
../modules/firewall
|
2023-07-16 18:50:06 +02:00
|
|
|
../modules/hostapd
|
2023-07-20 12:46:19 +02:00
|
|
|
../modules/bridge
|
2023-07-23 00:22:45 +02:00
|
|
|
../modules/ntp
|
2024-02-08 00:48:10 +01:00
|
|
|
../modules/schnapps
|
2023-08-10 23:53:21 +02:00
|
|
|
../modules/ssh
|
2024-01-07 17:43:43 +01:00
|
|
|
../modules/outputs/btrfs.nix
|
2024-01-08 19:58:07 +01:00
|
|
|
../modules/outputs/extlinux.nix
|
2023-02-26 00:12:55 +01:00
|
|
|
];
|
2023-05-20 23:34:57 +02:00
|
|
|
hostname = "rotuer";
|
2024-01-07 17:43:43 +01:00
|
|
|
rootfsType = "btrfs";
|
2024-01-08 19:54:49 +01:00
|
|
|
rootOptions = "subvol=@";
|
2024-01-08 19:58:07 +01:00
|
|
|
boot.loader.extlinux.enable = true;
|
2023-02-26 00:12:55 +01:00
|
|
|
|
2023-08-05 13:21:18 +02:00
|
|
|
services.hostap = svc.hostapd.build {
|
2023-10-07 23:23:44 +02:00
|
|
|
interface = config.hardware.networkInterfaces.wlan;
|
2023-02-26 00:12:55 +01:00
|
|
|
params = {
|
2024-02-11 10:10:03 +01:00
|
|
|
ssid = secrets.ssid;
|
2023-02-26 00:12:55 +01:00
|
|
|
hw_mode="g";
|
|
|
|
channel = "2";
|
|
|
|
ieee80211n = 1;
|
2023-07-23 00:37:01 +02:00
|
|
|
} // wirelessConfig;
|
2023-02-26 00:12:55 +01:00
|
|
|
};
|
|
|
|
|
2023-08-05 13:21:18 +02:00
|
|
|
services.hostap5 = svc.hostapd.build {
|
2023-10-07 23:23:44 +02:00
|
|
|
interface = config.hardware.networkInterfaces.wlan5;
|
2023-03-01 23:24:58 +01:00
|
|
|
params = rec {
|
2024-02-11 10:10:03 +01:00
|
|
|
ssid = "${secrets.ssid}5";
|
2023-03-01 23:24:58 +01:00
|
|
|
hw_mode="a";
|
|
|
|
channel = 36;
|
|
|
|
ht_capab = "[HT40+]";
|
|
|
|
vht_oper_chwidth = 1;
|
|
|
|
vht_oper_centr_freq_seg0_idx = channel + 6;
|
2024-02-11 16:24:08 +01:00
|
|
|
ieee80211n = 1;
|
2023-03-01 23:24:58 +01:00
|
|
|
ieee80211ac = 1;
|
2023-07-23 00:37:01 +02:00
|
|
|
} // wirelessConfig;
|
2023-03-01 23:24:58 +01:00
|
|
|
};
|
|
|
|
|
2023-08-28 00:45:27 +02:00
|
|
|
services.int = svc.network.address.build {
|
2023-09-01 18:57:22 +02:00
|
|
|
interface = svc.bridge.primary.build { ifname = "int"; };
|
2024-02-08 00:46:16 +01:00
|
|
|
family = "inet"; address ="${secrets.lan.prefix}.1"; prefixLength = 24;
|
2023-08-28 00:45:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
services.bridge = svc.bridge.members.build {
|
|
|
|
primary = services.int;
|
|
|
|
members = with config.hardware.networkInterfaces;
|
2023-10-07 23:23:44 +02:00
|
|
|
[ wlan
|
|
|
|
wlan5
|
2024-02-08 00:48:10 +01:00
|
|
|
lan0
|
|
|
|
lan1
|
|
|
|
lan2
|
|
|
|
lan3
|
|
|
|
lan4
|
|
|
|
];
|
2023-08-28 00:45:27 +02:00
|
|
|
};
|
2023-03-01 23:24:58 +01:00
|
|
|
|
2023-08-05 15:16:54 +02:00
|
|
|
services.ntp = svc.ntp.build {
|
2023-07-23 00:22:45 +02:00
|
|
|
pools = { "pool.ntp.org" = ["iburst"]; };
|
|
|
|
makestep = { threshold = 1.0; limit = 3; };
|
|
|
|
};
|
2023-04-23 19:22:39 +02:00
|
|
|
|
2023-08-10 23:53:21 +02:00
|
|
|
services.sshd = svc.ssh.build { };
|
2023-03-04 01:39:54 +01:00
|
|
|
|
2023-05-20 23:48:30 +02:00
|
|
|
users.root = secrets.root;
|
2023-03-04 01:39:54 +01:00
|
|
|
|
2023-02-26 00:12:55 +01:00
|
|
|
services.dns =
|
2023-06-01 00:29:05 +02:00
|
|
|
let interface = services.int;
|
2023-08-04 21:39:29 +02:00
|
|
|
in svc.dnsmasq.build {
|
2023-02-26 00:12:55 +01:00
|
|
|
resolvconf = services.resolvconf;
|
2023-06-01 00:29:05 +02:00
|
|
|
inherit interface;
|
|
|
|
ranges = [
|
2024-02-08 00:46:16 +01:00
|
|
|
"${secrets.lan.prefix}.10,${secrets.lan.prefix}.240"
|
2023-09-05 00:07:13 +02:00
|
|
|
# ra-stateless: sends router advertisements with the O and A
|
|
|
|
# bits set, and provides a stateless DHCP service. The client
|
|
|
|
# will use a SLAAC address, and use DHCP for other
|
|
|
|
# configuration information.
|
2023-08-28 00:20:58 +02:00
|
|
|
"::,constructor:$(output ${interface} ifname),ra-stateless"
|
2023-06-01 00:29:05 +02:00
|
|
|
];
|
2023-09-05 00:07:13 +02:00
|
|
|
|
|
|
|
# You can add static addresses for the DHCP server here. I'm
|
|
|
|
# not putting my actual MAC addresses in a public git repo ...
|
|
|
|
hosts = { } // lib.optionalAttrs (builtins.pathExists ./static-leases.nix) (import ./static-leases.nix);
|
|
|
|
|
2024-02-11 10:10:03 +01:00
|
|
|
domain = secrets.domainName;
|
2023-02-26 00:12:55 +01:00
|
|
|
};
|
|
|
|
|
2023-08-10 23:53:45 +02:00
|
|
|
services.wan = svc.pppoe.build {
|
2023-07-20 13:05:36 +02:00
|
|
|
interface = config.hardware.networkInterfaces.wan;
|
|
|
|
ppp-options = [
|
|
|
|
"debug" "+ipv6" "noauth"
|
|
|
|
"name" secrets.l2tp.name
|
|
|
|
"password" secrets.l2tp.password
|
|
|
|
];
|
|
|
|
};
|
2023-02-26 00:12:55 +01:00
|
|
|
|
|
|
|
services.resolvconf = oneshot rec {
|
|
|
|
dependencies = [ services.wan ];
|
|
|
|
name = "resolvconf";
|
|
|
|
up = ''
|
|
|
|
. ${serviceFns}
|
2023-03-04 00:06:18 +01:00
|
|
|
( in_outputs ${name}
|
2023-02-26 00:12:55 +01:00
|
|
|
echo "nameserver $(output ${services.wan} ns1)" > resolv.conf
|
|
|
|
echo "nameserver $(output ${services.wan} ns2)" >> resolv.conf
|
2023-08-28 21:53:45 +02:00
|
|
|
chmod 0444 resolv.conf
|
2023-02-26 00:12:55 +01:00
|
|
|
)
|
|
|
|
'';
|
|
|
|
};
|
2023-09-04 23:06:15 +02:00
|
|
|
|
2023-08-28 19:23:32 +02:00
|
|
|
filesystem =
|
|
|
|
let inherit (pkgs.pseudofile) dir symlink;
|
|
|
|
in dir {
|
|
|
|
etc = dir {
|
|
|
|
"resolv.conf" = symlink "${services.resolvconf}/.outputs/resolv.conf";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-09-01 00:24:23 +02:00
|
|
|
services.defaultroute4 = svc.network.route.build {
|
2023-02-26 00:12:55 +01:00
|
|
|
via = "$(output ${services.wan} address)";
|
|
|
|
target = "default";
|
|
|
|
dependencies = [ services.wan ];
|
|
|
|
};
|
|
|
|
|
2023-09-01 00:24:23 +02:00
|
|
|
services.defaultroute6 = svc.network.route.build {
|
2023-06-30 11:17:33 +02:00
|
|
|
via = "$(output ${services.wan} ipv6-peer-address)";
|
|
|
|
target = "default";
|
2023-09-01 00:24:23 +02:00
|
|
|
interface = services.wan;
|
2023-06-30 11:17:33 +02:00
|
|
|
};
|
|
|
|
|
2023-08-05 13:07:35 +02:00
|
|
|
services.firewall = svc.firewall.build {
|
2024-02-08 00:46:16 +01:00
|
|
|
ruleset =
|
|
|
|
let defaults = import ./demo-firewall.nix;
|
|
|
|
in lib.recursiveUpdate defaults secrets.firewallRules;
|
2023-07-16 18:04:01 +02:00
|
|
|
};
|
2023-06-20 21:20:32 +02:00
|
|
|
|
2023-09-01 18:34:47 +02:00
|
|
|
services.packet_forwarding = svc.network.forward.build { };
|
2023-02-26 00:12:55 +01:00
|
|
|
|
2023-09-25 00:29:30 +02:00
|
|
|
services.dhcp6c =
|
|
|
|
let client = svc.dhcp6c.client.build {
|
|
|
|
interface = services.wan;
|
|
|
|
};
|
|
|
|
in bundle {
|
|
|
|
name = "dhcp6c";
|
|
|
|
contents = [
|
|
|
|
(svc.dhcp6c.prefix.build {
|
|
|
|
inherit client;
|
|
|
|
interface = services.int;
|
|
|
|
})
|
|
|
|
(svc.dhcp6c.address.build {
|
|
|
|
inherit client;
|
|
|
|
interface = services.wan;
|
|
|
|
})
|
|
|
|
];
|
2023-07-09 00:07:07 +02:00
|
|
|
};
|
|
|
|
|
2023-06-20 21:13:59 +02:00
|
|
|
defaultProfile.packages = with pkgs; [
|
|
|
|
min-collect-garbage
|
2024-02-12 00:30:46 +01:00
|
|
|
nftables
|
|
|
|
strace
|
|
|
|
tcpdump
|
2023-06-20 21:13:59 +02:00
|
|
|
];
|
2023-12-13 22:54:15 +01:00
|
|
|
|
|
|
|
programs.busybox.applets = [
|
|
|
|
"fdisk" "sfdisk"
|
|
|
|
];
|
2023-02-26 00:12:55 +01:00
|
|
|
}
|