nixos-config/hosts/clunk.nix

177 lines
3.7 KiB
Nix
Raw Normal View History

2020-10-16 09:17:50 -07:00
{ lib, config, pkgs, ... }:
let
hostname = "clunk";
host-internal-ip = "10.0.0.1";
2020-10-24 09:14:46 -07:00
dns-proxy-ip = "10.0.0.2";
2020-10-16 09:17:50 -07:00
inherit (lib.strings) concatStringsSep;
in {
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
2020-10-24 09:14:46 -07:00
boot = {
runSize = "50%";
};
2020-10-16 09:17:50 -07:00
hardware.bluetooth.enable = false;
imports = [
../defaults.nix
../hardware-configuration.nix
];
fudo.common = {
profile = "server";
site = "russell";
};
2020-10-24 09:14:46 -07:00
fudo.local-network = {
enable = true;
dns-servers = [ host-internal-ip ];
gateway = host-internal-ip;
dhcp-interfaces = [ "intif0" ];
2020-11-04 10:33:14 -08:00
dns-serve-ips = [ host-internal-ip "127.0.0.1" "127.0.1.1" "::1" ];
2020-10-24 09:14:46 -07:00
# Using a pihole running in docker, see below
recursive-resolver = "${host-internal-ip} port 5353";
server-ip = host-internal-ip;
};
2020-10-16 09:17:50 -07:00
networking = {
hostName = hostname;
nameservers = [ host-internal-ip ];
# Create a bridge for VMs to use
macvlans = {
intif0 = {
interface = "enp2s0";
mode = "bridge";
};
};
2020-10-24 09:14:46 -07:00
firewall = {
enable = true;
2020-11-04 10:33:14 -08:00
trustedInterfaces = [ "intif0" "docker0" ];
2020-10-24 09:14:46 -07:00
};
2020-10-16 09:17:50 -07:00
interfaces = {
enp2s0.useDHCP = false;
enp3s0.useDHCP = false;
enp4s0.useDHCP = false;
enp1s0.useDHCP = true;
intif0 = {
useDHCP = false;
# Result of:
# echo clunk-intif0|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/'
macAddress = "02:44:d1:eb:c3:6b";
ipv4.addresses = [
{
address = host-internal-ip;
prefixLength = 22;
}
2020-10-24 09:14:46 -07:00
{
address = dns-proxy-ip;
prefixLength = 32;
}
2020-10-16 09:17:50 -07:00
];
};
};
nat = {
enable = true;
externalInterface = "enp1s0";
internalInterfaces = ["intif0"];
};
};
fudo = {
2020-10-24 09:14:46 -07:00
garbage-collector = {
enable = true;
timing = "hourly";
};
2020-10-16 09:17:50 -07:00
secure-dns-proxy = {
enable = true;
2020-10-24 09:14:46 -07:00
port = 53;
2020-10-16 09:17:50 -07:00
upstream-dns = [
2020-11-04 10:33:14 -08:00
"https://1.1.1.1/dns-query"
"https://1.0.0.1/dns-query"
#"https://9.9.9.9/dns-query"
2020-10-16 09:17:50 -07:00
];
bootstrap-dns = "1.1.1.1";
2020-10-24 09:14:46 -07:00
listen-ips = [dns-proxy-ip];
2020-10-16 09:17:50 -07:00
};
};
environment.systemPackages = with pkgs; [
dnsproxy
];
virtualisation = {
docker = {
enable = true;
autoPrune.enable = true;
enableOnBoot = true;
};
};
docker-containers = {
pihole = {
2020-10-24 09:14:46 -07:00
image = "pihole/pihole:v5.1.2";
2020-10-16 09:17:50 -07:00
ports = [
"5353:53/tcp"
"5353:53/udp"
"3080:80/tcp"
];
environment = {
ServerIP = host-internal-ip;
2020-10-24 09:14:46 -07:00
VIRTUAL_HOST = "dns-hole.rus.selby.ca";
# Not working?
DNS1 = dns-proxy-ip;
#DNS1 = "1.1.1.1";
2020-10-16 09:17:50 -07:00
};
volumes = [
"/srv/pihole/etc-pihole/:/etc/pihole/"
"/srv/pihole/etc-dnsmasq.d/:/etc/dnsmasq.d/"
];
2020-10-24 09:14:46 -07:00
};
};
services.nginx = {
enable = true;
recommendedOptimisation = true;
recommendedGzipSettings = true;
virtualHosts = {
"dns-hole.rus.selby.ca" = {
serverAliases = [
"pihole.rus.selby.ca"
"hole.rus.selby.ca"
"pihole"
"dns-hole"
"hole"
];
locations."/" = {
proxyPass = "http://127.0.0.1:3080";
extraConfig = ''
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-By $server_addr:$server_port;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
'';
};
};
2020-10-16 09:17:50 -07:00
};
};
}