Add MVP router flake with VM test and tmux lab
router.* schema (wan, lans, dns.forwarders) compiled to systemd-networkd, a generated nftables ruleset with NAT, Kea DHCPv4 and Unbound, plus build-time assertions against lock-out and interface conflicts. tests/basic.nix is a three-node VM test (upstream/router/client) covering WAN DHCP, LAN DHCP and DNS, NAT, WAN-deny and LAN SSH/ping. `nix run .#lab` boots the same topology in tmux with one console pane per VM and the driver REPL. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
{
|
||||
description = "nixos-router: a NixOS-based distribution for routers/firewalls";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
systems = [ "x86_64-linux" "aarch64-linux" ];
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
|
||||
in
|
||||
{
|
||||
nixosModules = {
|
||||
router = ./modules/router;
|
||||
default = self.nixosModules.router;
|
||||
};
|
||||
|
||||
# VM tests need KVM; only wired up for x86_64 until aarch64 CI exists.
|
||||
checks.x86_64-linux = import ./tests {
|
||||
inherit self;
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
};
|
||||
|
||||
# `nix run .#lab`: boot the basic test topology in tmux, one console pane
|
||||
# per VM plus the interactive test-driver REPL.
|
||||
apps.x86_64-linux.lab =
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
test = self.checks.x86_64-linux.basic;
|
||||
lab = pkgs.writeShellApplication {
|
||||
name = "router-lab";
|
||||
runtimeInputs = with pkgs; [ tmux util-linux gnugrep coreutils ];
|
||||
text = import ./tests/lab.nix {
|
||||
inherit (pkgs) lib;
|
||||
driver = test.driverInteractive;
|
||||
nodes = builtins.attrNames test.nodes;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
type = "app";
|
||||
program = "${lab}/bin/router-lab";
|
||||
};
|
||||
|
||||
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user