Configuration Examples

Network and Firewall

{
  uci.settings = {
    system.system = [ { _type = "system"; hostname = "rauter"; } ];
    network = {
      lan = { _type = "interface"; device = "br-lan"; proto = "dhcp"; };
      wan = { _type = "interface"; proto = "pppoe"; username = "@wan_user@"; password = "@wan_pass@"; };
    };
    firewall.guest = { _type = "zone"; name = "guest"; network = [ "guest" ]; input = "REJECT"; output = "ACCEPT"; };
  };
  uci.watchdogTimeout = 120;
}

Wireless

Secrets use @name@ placeholders (this project's syntax, not sops-nix's {{name}}), resolved from decrypted SOPS values in memory at compile time.

{
  uci.settings.wireless = {
    radio0 = { _type = "wifi-device"; type = "mac80211"; channel = "auto"; band = "2g"; };
    default_radio0 = {
      _type = "wifi-iface"; device = "radio0"; network = "lan";
      mode = "ap"; ssid = "home-2.4"; encryption = "sae-mixed"; key = "@wifi_password@";
    };
  };
  uci.secrets.sops.files = [ ./secrets.yml ];
}

Packages

opkgFeeds and apkRepositories are mutually exclusive and must match packageManager.

{
  uci.packageManager = "opkg"; # or "apk"
  uci.packages = [ "-tcpdump" "htop" ];
  uci.packageSources = {
    opkgFeeds = [ "src/gz custom https://dl.openwrt.org/packages" ];
    # apkRepositories = [ "https://dl.openwrt.org/packages" ];
    localPackages = [ "./packages/luci-app-custom_1.0_all.ipk" ];
  };
}

Custom Files

{
  uci.files = [
    { path = "/etc/config.txt"; content = "key=value\n"; }
    {
      path = "/usr/bin/blob";
      base64 = "aGVsbG8=";
      executable = true;
      checksum = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824";
    }
  ];
}

Raw UCI Commands

{
  uci.rawUci = [
    "uci rename network.lan=lan0"
    "uci reorder wireless.@wifi-iface[0]=1"
  ];
}

Firmware Build

exampleFirmware = uci.buildFirmware {
  configuration = ./example.nix;
  profile = "linksys_e8450-ubi";
};