From f5681326f3c01e52cbf6cbc625224c1a95f8fe17 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 21 Mar 2023 22:57:19 -0400 Subject: add config for turret (openwrt router) --- .gitattributes | 1 + flake.lock | 21 +++ flake.nix | 7 + hosts/turret/default.nix | 38 +++++ hosts/turret/files/etc/config/dhcp | 55 +++++++ hosts/turret/files/etc/config/dropbear | 5 + hosts/turret/files/etc/config/firewall | 189 ++++++++++++++++++++++++ hosts/turret/files/etc/config/https-dns-proxy | 18 +++ hosts/turret/files/etc/config/luci | 41 +++++ hosts/turret/files/etc/config/network | 29 ++++ hosts/turret/files/etc/config/rpcd | 10 ++ hosts/turret/files/etc/config/system | 16 ++ hosts/turret/files/etc/config/ucitrack | 56 +++++++ hosts/turret/files/etc/config/uhttpd | 31 ++++ hosts/turret/files/etc/config/wireless | Bin 0 -> 827 bytes hosts/turret/files/etc/dropbear/authorized_keys | 1 + util/host.nix | 2 +- 17 files changed, 519 insertions(+), 1 deletion(-) create mode 100644 .gitattributes create mode 100644 hosts/turret/default.nix create mode 100644 hosts/turret/files/etc/config/dhcp create mode 100644 hosts/turret/files/etc/config/dropbear create mode 100644 hosts/turret/files/etc/config/firewall create mode 100644 hosts/turret/files/etc/config/https-dns-proxy create mode 100644 hosts/turret/files/etc/config/luci create mode 100644 hosts/turret/files/etc/config/network create mode 100644 hosts/turret/files/etc/config/rpcd create mode 100644 hosts/turret/files/etc/config/system create mode 100644 hosts/turret/files/etc/config/ucitrack create mode 100644 hosts/turret/files/etc/config/uhttpd create mode 100644 hosts/turret/files/etc/config/wireless create mode 100644 hosts/turret/files/etc/dropbear/authorized_keys diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..ec504d9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +hosts/turret/files/etc/config/wireless filter=git-crypt diff=git-crypt diff --git a/flake.lock b/flake.lock index 8259a38..3f59ef3 100644 --- a/flake.lock +++ b/flake.lock @@ -380,6 +380,26 @@ "type": "github" } }, + "openwrt-imagebuilder": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1679392309, + "narHash": "sha256-oSEr3T+kPtqyEJaKdlOtFEKdVw3/CyWpydzVRqlnaI4=", + "owner": "astro", + "repo": "nix-openwrt-imagebuilder", + "rev": "3760cbcd8b5b7ca7fba823c0a942e4f8279df1a1", + "type": "github" + }, + "original": { + "owner": "astro", + "repo": "nix-openwrt-imagebuilder", + "type": "github" + } + }, "pre-commit-hooks": { "inputs": { "flake-compat": [ @@ -423,6 +443,7 @@ "nixpkgs": "nixpkgs", "nixpkgsUnstable": "nixpkgsUnstable", "nur": "nur", + "openwrt-imagebuilder": "openwrt-imagebuilder", "pre-commit-hooks": "pre-commit-hooks" } }, diff --git a/flake.nix b/flake.nix index 6715c5f..e811bf6 100644 --- a/flake.nix +++ b/flake.nix @@ -38,6 +38,10 @@ }; nixos-hardware.url = "github:NixOS/nixos-hardware"; nur.url = "github:nix-community/NUR"; + openwrt-imagebuilder = { + url = "github:astro/nix-openwrt-imagebuilder"; + inputs.nixpkgs.follows = "nixpkgs"; + }; pre-commit-hooks = { url = "github:cachix/pre-commit-hooks.nix"; inputs.nixpkgs.follows = "nixpkgsUnstable"; @@ -51,6 +55,7 @@ self, nixpkgs, flake-utils, + openwrt-imagebuilder, pre-commit-hooks, ... }: let @@ -99,5 +104,7 @@ }) // { nixosConfigurations = mapHosts hosts; + + packages.x86_64-linux.turret = nixpkgs.legacyPackages.x86_64-linux.callPackage ./hosts/turret {inherit openwrt-imagebuilder;}; }; } diff --git a/hosts/turret/default.nix b/hosts/turret/default.nix new file mode 100644 index 0000000..faac3d2 --- /dev/null +++ b/hosts/turret/default.nix @@ -0,0 +1,38 @@ +{ + pkgs, + openwrt-imagebuilder, + ... +}: let + inherit (pkgs) runCommand; + inherit (pkgs.stdenv) mkDerivation; + inherit (openwrt-imagebuilder.lib) build profiles; + wrtProfiles = profiles { + inherit pkgs; + release = "22.03.3"; + }; + config = mkDerivation { + name = "openwrt-config-files"; + src = ./files; + installPhase = '' + mkdir -p $out + cp -r * $out/ + ''; + }; + image = + wrtProfiles.identifyProfile "netgear_wac104" + // { + packages = ["https-dns-proxy"]; + + files = runCommand "image-files" {} '' + mkdir -p $out/etc/uci-defaults + cat > $out/etc/uci-defaults/99-custom <