nixos-config/hosts/nostromo.nix

240 lines
5.4 KiB
Nix
Raw Normal View History

2020-02-03 20:51:49 -08:00
{ lib, config, pkgs, ... }:
2019-12-25 15:20:36 -08:00
2020-11-16 12:39:37 -08:00
with lib;
2019-12-25 15:20:36 -08:00
let
hostname = "nostromo";
2020-06-07 19:11:58 -07:00
host-internal-ip = "10.0.0.1";
2019-12-25 15:20:36 -08:00
in {
2020-11-16 12:39:37 -08:00
environment.systemPackages = with pkgs; [
dnsproxy
google-photos-uploader
libguestfs-with-appliance
libvirt
powerdns
virtmanager
];
2019-12-25 15:20:36 -08:00
boot.kernelModules = [ "kvm-amd" ];
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
2020-06-07 19:11:58 -07:00
boot.loader.grub.device = "/dev/sda";
2019-12-25 15:20:36 -08:00
2020-02-18 10:58:47 -08:00
hardware.bluetooth.enable = false;
imports = [ ../defaults.nix ../hardware-configuration.nix ];
2019-12-25 15:20:36 -08:00
2020-02-18 10:58:47 -08:00
fudo.common = {
profile = "server";
site = "seattle";
};
2020-06-07 19:11:58 -07:00
fudo.local-network = {
enable = true;
# See fudo/sites/seattle.nix for general settings
dns-servers = [ host-internal-ip ];
2020-06-20 15:36:00 -07:00
gateway = host-internal-ip;
2020-06-07 19:11:58 -07:00
dhcp-interfaces = [ "intif0" ];
dns-serve-ips = [ host-internal-ip "127.0.0.1" "127.0.1.1" ];
# Using a pihole running in docker, see below
recursive-resolver = "${host-internal-ip} port 5353";
server-ip = host-internal-ip;
};
2020-06-20 15:36:00 -07:00
fudo.slynk = {
2020-10-16 09:09:44 -07:00
# NOTE: for now, had to do: XDG_RUNTIME_DIR=/run/user/$UID systemctl start --user slynk
2020-06-20 15:36:00 -07:00
enable = true;
};
2020-11-23 14:22:51 -08:00
# systemd.network.networks.eno2 = {
# dhcpV6Config = {
# IPv6PrefixDelegation = "dhcpv6";
# PrefixDelegationHint = 60;
# };
# };
systemd.network.networks.eno2 = {
extraConfig = {
IPv6AcceptRA = true;
IPv6PrefixDelegation = "dhcpv6";
};
};
2019-12-25 15:20:36 -08:00
networking = {
hostName = hostname;
2020-06-07 19:11:58 -07:00
nameservers = [ host-internal-ip ];
2019-12-25 15:20:36 -08:00
2020-11-23 14:22:51 -08:00
dhcpcd.extraConfig = ''
interface eno2
ia_na 1
ia_pd 2 eno2/0
'';
2020-11-23 14:22:51 -08:00
2019-12-25 15:20:36 -08:00
# Create a bridge for VMs to use
2020-06-07 19:11:58 -07:00
macvlans = {
intif0 = {
interface = "eno1";
mode = "bridge";
};
2019-12-25 15:20:36 -08:00
};
interfaces = {
2020-06-07 19:11:58 -07:00
eno1.useDHCP = false;
eno3.useDHCP = false;
eno4.useDHCP = false;
enp33s0f0.useDHCP = false;
enp33s0f1.useDHCP = false;
enp9s0f0.useDHCP = false;
enp9s0f1.useDHCP = false;
eno2 = { useDHCP = true; };
2020-06-07 19:11:58 -07:00
intif0 = {
useDHCP = false;
2019-12-25 15:20:36 -08:00
macAddress = "46:54:76:06:f1:10";
ipv4.addresses = [
{
2020-06-07 19:11:58 -07:00
address = host-internal-ip;
2020-02-03 20:51:49 -08:00
prefixLength = 22;
}
{
address = "10.0.10.2";
prefixLength = 24;
2019-12-25 15:20:36 -08:00
}
];
};
2020-06-07 19:11:58 -07:00
};
nat = {
enable = true;
externalInterface = "eno2";
2020-11-16 12:39:37 -08:00
internalInterfaces = [ "intif0" ];
};
};
users = {
users = { fudo-client = { isSystemUser = true; }; };
2020-11-23 14:22:51 -08:00
groups = {
backplane-powerdns = { members = [ "backplane-powerdns" ]; };
backplane-dns = { members = [ "backplane-dns" ]; };
2020-11-23 14:22:51 -08:00
};
2019-12-25 15:20:36 -08:00
};
2020-02-18 10:58:47 -08:00
fudo = {
2020-11-16 12:39:37 -08:00
client.dns = {
enable = true;
ipv4 = true;
ipv6 = true;
user = "fudo-client";
external-interface = "eno2";
password-file = "/srv/client/secure/client.passwd";
};
2020-06-22 11:10:36 -07:00
secure-dns-proxy = {
enable = true;
port = 3535;
upstream-dns = [
"https://cloudflare-dns.com/dns-query"
# "https://dns.adguard.com/dns-query"
];
bootstrap-dns = "1.1.1.1";
};
2020-10-16 09:09:44 -07:00
netinfo-email = {
enable = true;
env-file = "/srv/netinfo/secure/env";
};
2020-02-18 10:58:47 -08:00
};
2019-12-25 15:20:36 -08:00
2020-06-07 19:11:58 -07:00
virtualisation = {
docker = {
enable = true;
autoPrune.enable = true;
enableOnBoot = true;
};
libvirtd = {
enable = true;
qemuPackage = pkgs.qemu_kvm;
onShutdown = "shutdown";
};
};
docker-containers = {
pihole = {
image = "pihole/pihole:4.3.2-1";
ports = [ "5353:53/tcp" "5353:53/udp" "3080:80/tcp" ];
2020-06-07 19:11:58 -07:00
environment = {
ServerIP = host-internal-ip;
VIRTUAL_HOST = "dns-hole.sea.fudo.org";
DNS1 = "1.1.1.1";
DNS2 = "8.8.8.8";
};
volumes = [
"/srv/pihole/etc-pihole/:/etc/pihole/"
"/srv/pihole/etc-dnsmasq.d/:/etc/dnsmasq.d/"
];
# TODO: DNS-over-HTTPS via cloudflared
2020-06-20 15:36:00 -07:00
# extraDockerOptions = [
# "--dns=1.1.1.1"
# ];
2020-06-07 19:11:58 -07:00
};
2019-12-25 15:20:36 -08:00
};
fudo.ipfs = {
enable = true;
users = [ "niten" ];
api-address = "/ip4/${host-internal-ip}/tcp/5001";
};
security.acme.certs."sea-camera.fudo.link".email = "niten@fudo.org";
security.acme.certs."sea-camera-od.fudo.link".email = "niten@fudo.org";
2020-02-03 20:51:49 -08:00
services = {
2020-06-07 19:11:58 -07:00
nginx = {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedTlsSettings = true;
recommendedProxySettings = true;
2020-06-07 19:11:58 -07:00
virtualHosts = {
"sea-camera.fudo.link" = {
enableACME = true;
forceSSL = true;
2020-06-07 19:11:58 -07:00
locations."/" = {
proxyPass = "http://panopticon.sea.fudo.org/";
extraConfig = ''
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
'';
};
};
2020-06-07 19:11:58 -07:00
"sea-camera-od.fudo.link" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://panopticon-od.sea.fudo.org/";
2020-06-07 19:11:58 -07:00
extraConfig = ''
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
2020-06-07 19:11:58 -07:00
'';
};
};
"pihole.sea.fudo.org" = {
serverAliases = [ "dns-hole.sea.fudo.org" "hole.sea.fudo.org" ];
locations."/" = { proxyPass = "http://127.0.0.1:3000"; };
};
2020-06-07 19:11:58 -07:00
};
};
2020-02-03 20:51:49 -08:00
};
2019-12-25 15:20:36 -08:00
}