A hardened NixOS configuration for single board computers that routes all traffic through Tor with SSH access over USB ethernet.
| Device | WiFi Chip | WiFi Driver | USB Mode |
|---|---|---|---|
| Radxa Zero 3W | AIC8800 (SDIO) | aic8800_fdrv (out-of-tree) | dwc3 |
| Raspberry Pi Zero 2W | BCM43439 (on-board) | brcmfmac (mainline) | dwc2 |
- SSH over USB Ethernet: Access the system through USB ethernet gadget
- Interactive WiFi Setup: Run
wifi-setupcommand to connect to WiFi networks - Tor Transparent Proxy: All network traffic automatically routed through Tor
- Network Isolation: Direct internet connections blocked by iptables rules
- Security Hardening: IPv6 disabled, DNS leak protection, traffic monitoring
- Cross-platform Build: Supports building on x86_64 and aarch64 systems
- Multi-device Support: Single codebase for multiple SBC targets
# Enable Nix flakes
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.confThis project builds NixOS images for Linux (aarch64-linux). On macOS, you need a Linux environment via OrbStack.
# Clone and enter directory
git clone <this-repo>
cd nixognito
# Create a NixOS VM (or use Ubuntu/Debian and install Nix)
orb create nixos
# Enter the VM
orb shell -m nixos
# Edit /etc/nixos/configuration.nix and add the following line:
# nix.settings.experimental-features = [ "nix-command" "flakes" ];
# Rebuild NixOS
nixos-rebuild switch --upgradeThen follow the Linux build instructions below.
# Clone and enter directory
git clone <this-repo>
cd nixognito
# Build for Radxa Zero 3W
nix build .#sdImage-radxa-zero3w
# Build for Raspberry Pi Zero 2W
nix build .#sdImage-rpi-zero2w# Radxa Zero 3W
sudo dd if=result/sd-image/nixognito-radxa-zero3w-*.img of=/dev/sdX bs=4M status=progress oflag=sync
# Raspberry Pi Zero 2W
sudo dd if=result/sd-image/nixognito-rpi-zero2w-*.img of=/dev/sdX bs=4M status=progress oflag=syncβββ configuration.nix # Shared system configuration (users, packages, boot)
βββ devices/
β βββ radxa-zero3w/
β β βββ default.nix # Radxa Zero 3W hardware, SD image layout
β β βββ aic8800.nix # AIC8800 WiFi driver and firmware
β βββ rpi-zero2w/
β βββ default.nix # Raspberry Pi Zero 2W hardware, firmware, SD image
βββ networking.nix # NetworkManager, WiFi setup script
βββ tor-proxy.nix # Tor transparent proxy + service dependencies
βββ usb-ssh.nix # USB gadget ethernet (g_ether)
βββ security-hardening.nix # Additional security rules
βββ flake.nix # Nix flake with multi-device build targets
βββ README.md # This file
- Insert SD card into your board
- Connect USB-C cable (Radxa) or micro-USB cable (RPi) between board and your computer
- Power on the board (wait ~30 seconds for boot)
When you connect the board, macOS will create a new network interface. Configure it:
# Find the interface name (e.g., en7)
networksetup -listallhardwareports | grep -A1 "RNDIS/Ethernet"
# Or check System Settings β Network for "RNDIS/Ethernet Gadget"
# Assign an IP to the macOS side (replace en7 with your interface)
sudo ifconfig en7 192.168.64.1 netmask 255.255.255.0 up
# SSH to the board (password: nixognito)
ssh [email protected]Alternatively, enable Internet Sharing in System Settings:
- Go to System Settings β General β Sharing β Internet Sharing
- Share your WiFi/Ethernet to the new USB interface
- The board will get an IP via DHCP
# Find the new interface (usually usb0 or enp0s*)
ip link show
# Assign an IP
sudo ip addr add 192.168.64.1/24 dev <interface>
sudo ip link set <interface> up
# SSH to the board (password: nixognito)
ssh [email protected]Once logged in via SSH, run the WiFi setup wizard:
wifi-setupThis will scan for available networks and prompt for credentials.
The system follows a strict initialization sequence to ensure Tor works correctly:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. BOOT β
β βββΊ USB Ethernet active (192.168.64.2) β
β βββΊ SSH available for user access β
β βββΊ NO internet connectivity yet β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 2. USER ACTION β
β βββΊ User SSHs in via USB ethernet β
β βββΊ User runs `wifi-setup` β
β βββΊ Board connects to WiFi β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 3. wifi-online.service β
β βββΊ Detects wlan0 has default route β
β βββΊ Verifies internet connectivity (ping 1.1.1.1) β
β βββΊ Triggers dependent services β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 4. systemd-timesyncd (requires: wifi-online) β
β βββΊ Starts NTP daemon β
β βββΊ DIRECT internet access (bypasses Tor) β
β βββΊ Contacts NTP servers to sync clock β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 5. time-synced.service (requires: timesyncd) β
β βββΊ Waits for NTPSynchronized=yes β
β βββΊ Ensures clock is actually synced before proceeding β
β βββΊ Tor requires accurate time for certificate validation β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 6. tor.service (requires: time-synced, wifi-online) β
β βββΊ Starts Tor daemon β
β βββΊ Establishes Tor circuits β
β βββΊ Opens SOCKS (9050), TransPort (9040), DNS (5353) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 7. tor-transparent-proxy.service (requires: tor) β
β βββΊ Configures iptables rules β
β βββΊ Redirects all TCP to Tor TransPort β
β βββΊ Redirects all DNS to Tor DNSPort β
β βββΊ Blocks non-Tor traffic β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 8. OPERATIONAL STATE β
β βββΊ All traffic forced through Tor β
β βββΊ Only tor and timesyncd can access internet directly β
β βββΊ All other processes use Tor or are blocked β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Only two system users can access the internet directly:
| User | Purpose | Why Direct Access? |
|---|---|---|
tor |
Tor daemon | Must connect to Tor relays directly |
systemd-timesync |
NTP time sync | Accurate time required before Tor can start |
All other processes are forced through Tor's transparent proxy or rejected.
- All outbound TCP traffic redirected through Tor (port 9040)
- DNS queries routed through Tor DNS proxy (port 5353)
- Direct internet access blocked by iptables REJECT rules
- Local network access preserved (192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12)
- USB ethernet (192.168.64.0/24) always accessible for management
- IPv6 completely disabled
- ICMP redirects disabled
- Source routing disabled
- Reverse path filtering enabled
ββββββββββββββββββββ βββββββββββββββββββββββββ βββββββββββββββββββ
β Client Computer ββββββββ USB Ethernet Gadget ββββββββ SBC (Radxa/RPi) β
β 192.168.64.1 β β 192.168.64.0/24 β β 192.168.64.2 β
ββββββββββββββββββββ βββββββββββββββββββββββββ βββββββββββββββββββ
β
β WiFi (wlan0)
βΌ
ββββββββββββββββββββ βββββββββββββββββββββββββ βββββββββββββββββββ
β Internet ββββββββ Tor Network ββββββββ WiFi Router β
ββββββββββββββββββββ βββββββββββββββββββββββββ βββββββββββββββββββ
# Build for Radxa Zero 3W
nix build .#sdImage-radxa-zero3w
# Build for Raspberry Pi Zero 2W
nix build .#sdImage-rpi-zero2w
# Cross-compile from x86_64 to aarch64
nix build .#packages.x86_64-linux.sdImage-radxa-zero3w
nix build .#packages.x86_64-linux.sdImage-rpi-zero2w
# Test configuration without building image
nix build .#nixosConfigurations.nixognito-radxa-zero3w.config.system.build.toplevel
nix build .#nixosConfigurations.nixognito-rpi-zero2w.config.system.build.toplevel
# Enter development shell
nix developModify tor-proxy.nix to customize Tor settings:
services.tor.settings = {
ExitNodes = "{us}"; # Specify exit countries
UseBridges = true; # Enable bridge mode
StrictNodes = true; # Enforce node restrictions
};Adjust monitoring intervals in security-hardening.nix:
systemd.services.network-lockdown.timer = {
OnCalendar = "*:0/1"; # Check every minute
};To add support for another SBC:
- Create
devices/<device-name>.nixfollowing the structure of existing device modules - Add the device name to the
deviceslist inflake.nix - Configure: device tree, kernel modules, WiFi driver/firmware, boot params, SD image layout
- Check USB cable connection (must support data, not just charging)
- Verify interface appeared:
ifconfig(macOS) orip link(Linux) - Check board booted: wait 30+ seconds after power on
- Try a different USB port
- Run
wifi-setupto reconfigure - Check available networks:
nmcli dev wifi list - Monitor logs:
journalctl -f -u NetworkManager
- Check service chain:
systemctl status wifi-online systemd-timesyncd time-synced tor - WiFi must be connected first - run
wifi-setup - Monitor initialization:
journalctl -f -u wifi-online -u systemd-timesyncd -u time-synced -u tor - Check time sync:
timedatectl status
- Check Tor status:
systemctl status tor - Test SOCKS proxy:
curl --socks5 127.0.0.1:9050 https://check.torproject.org/api/ip - View Tor logs:
journalctl -f -u tor - Check transparent proxy:
systemctl status tor-transparent-proxy
- Test Tor routing:
curl https://check.torproject.org/api/ip(should showIsTor: true) - Check iptables rules:
iptables -t nat -L OUTPUT -v -n - Check filter rules:
iptables -L OUTPUT -v -n
# Test configuration syntax
nix flake check
# Build configuration only
nix build .#nixosConfigurations.nixognito-radxa-zero3w.config.system.build.toplevel
# Full image build
nix build .#sdImage-radxa-zero3w- Test changes thoroughly with
nix flake check - Verify security model isn't compromised
- Update documentation for new features
- Test on actual SBC hardware when possible
This configuration is provided as-is for educational and defensive security purposes only.