2020-06-07 14:03:12 +00:00
|
|
|
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2022-01-23 16:57:20 +00:00
|
|
|
{ depot, lib, pkgs, config, ... }:
|
2020-05-05 23:28:23 +00:00
|
|
|
let
|
2020-05-31 22:53:39 +00:00
|
|
|
vhostsConfig = {
|
|
|
|
int = rec {
|
|
|
|
proxy = _apply (value: { locations."/".proxyPass = value; }) {
|
|
|
|
"deluge.int.lukegb.com" = "http://localhost:8112";
|
|
|
|
"radarr.int.lukegb.com" = "http://localhost:7878";
|
|
|
|
"sonarr.int.lukegb.com" = "http://localhost:8989";
|
|
|
|
};
|
|
|
|
serve = _apply (value: { root = value; }) {
|
|
|
|
"int.lukegb.com" = depot.web.int;
|
2020-12-30 00:57:53 +00:00
|
|
|
"logged-out.int.lukegb.com" = depot.web.logged-out-int;
|
2020-05-31 22:53:39 +00:00
|
|
|
};
|
2021-10-19 06:06:37 +00:00
|
|
|
other = _apply lib.id {
|
|
|
|
"content.int.lukegb.com" = {
|
2021-10-31 12:35:05 +00:00
|
|
|
listen = [{
|
2022-09-01 23:22:16 +00:00
|
|
|
addr = "[${config.my.ip.tailscale6}]";
|
|
|
|
port = 80;
|
|
|
|
} {
|
2021-10-31 12:35:05 +00:00
|
|
|
addr = config.my.ip.tailscale;
|
|
|
|
port = 80;
|
2022-09-01 23:22:16 +00:00
|
|
|
} {
|
|
|
|
addr = "[${config.my.ip.tailscale6}]";
|
|
|
|
port = 18081;
|
2021-10-31 12:35:05 +00:00
|
|
|
} {
|
|
|
|
addr = config.my.ip.tailscale;
|
|
|
|
port = 18081;
|
|
|
|
}];
|
2021-10-19 06:06:37 +00:00
|
|
|
locations."/" = {
|
|
|
|
alias = "/store/content/";
|
|
|
|
extraConfig = ''
|
|
|
|
autoindex on;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2020-12-28 15:54:43 +00:00
|
|
|
_apply = f: builtins.mapAttrs (name: value: lib.recursiveUpdate hostBase (f value));
|
2020-05-31 22:53:39 +00:00
|
|
|
};
|
2020-05-31 22:28:01 +00:00
|
|
|
};
|
2021-10-19 06:06:37 +00:00
|
|
|
vhosts = vhostsConfig.int.proxy // vhostsConfig.int.serve // vhostsConfig.int.other;
|
2020-12-28 15:54:43 +00:00
|
|
|
hostBase = {
|
|
|
|
listen = [{
|
|
|
|
addr = config.my.ip.tailscale;
|
|
|
|
port = 80;
|
2022-09-01 23:22:16 +00:00
|
|
|
} {
|
|
|
|
addr = "[${config.my.ip.tailscale6}]";
|
|
|
|
port = 80;
|
2020-12-28 15:54:43 +00:00
|
|
|
}];
|
2020-05-31 22:28:01 +00:00
|
|
|
};
|
2020-05-05 23:28:23 +00:00
|
|
|
in {
|
2020-05-08 22:26:21 +00:00
|
|
|
imports = [
|
|
|
|
../lib/zfs.nix
|
|
|
|
../lib/bgp.nix
|
2021-03-20 02:03:23 +00:00
|
|
|
../lib/coredns/default.nix
|
2022-01-24 22:08:38 +00:00
|
|
|
../lib/deluge.nix
|
2022-01-23 16:58:29 +00:00
|
|
|
../lib/plex.nix
|
2020-05-08 22:26:21 +00:00
|
|
|
];
|
|
|
|
|
2020-05-05 23:28:23 +00:00
|
|
|
boot.initrd.availableKernelModules = [
|
|
|
|
"xhci_pci"
|
|
|
|
"ahci"
|
|
|
|
"nvme"
|
|
|
|
"usbhid"
|
|
|
|
"usb_storage"
|
|
|
|
"sd_mod"
|
|
|
|
"sr_mod"
|
|
|
|
];
|
2020-05-08 22:26:21 +00:00
|
|
|
boot.kernelModules = [ "kvm-intel" ];
|
2020-05-05 23:28:23 +00:00
|
|
|
|
|
|
|
powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
|
|
|
|
|
|
|
|
fileSystems = let
|
|
|
|
zfs = device: {
|
|
|
|
device = device;
|
|
|
|
fsType = "zfs";
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
"/" = zfs "zfast/local/root";
|
|
|
|
"/nix" = zfs "zfast/local/nix";
|
|
|
|
"/persist" = zfs "zfast/safe/persist";
|
|
|
|
"/home" = zfs "zfast/safe/home";
|
|
|
|
"/store" = zfs "zslow/local/store";
|
|
|
|
|
|
|
|
"/boot" = {
|
|
|
|
device = "/dev/disk/by-label/ESP";
|
|
|
|
fsType = "vfat";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-01-30 20:30:20 +00:00
|
|
|
nix.settings.max-jobs = lib.mkDefault 12;
|
2020-05-05 23:28:23 +00:00
|
|
|
|
|
|
|
# Use systemd-boot.
|
|
|
|
boot.loader.systemd-boot.enable = true;
|
|
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
|
|
|
|
|
|
|
# Networking!
|
|
|
|
networking = {
|
|
|
|
hostName = "clouvider-fra01";
|
|
|
|
domain = "as205479.net";
|
|
|
|
hostId = "9e983570";
|
|
|
|
|
|
|
|
nameservers = [
|
|
|
|
"2001:4860:4860::8888"
|
|
|
|
"2001:4860:4860::8844"
|
|
|
|
"8.8.8.8"
|
|
|
|
"8.8.4.4"
|
|
|
|
];
|
|
|
|
defaultGateway = {
|
|
|
|
address = "193.228.196.56";
|
|
|
|
interface = "enp1s0";
|
|
|
|
};
|
|
|
|
defaultGateway6 = {
|
|
|
|
address = "2a0f:93c0:0:22::1";
|
|
|
|
interface = "enp1s0";
|
|
|
|
};
|
|
|
|
interfaces.enp1s0 = {
|
|
|
|
ipv4.addresses = [{ address = "193.228.196.57"; prefixLength = 31; }];
|
|
|
|
ipv6.addresses = [{ address = "2a0f:93c0:0:22::2"; prefixLength = 126; }];
|
|
|
|
};
|
|
|
|
firewall.allowPing = true;
|
2021-01-15 00:58:36 +00:00
|
|
|
firewall.allowedTCPPorts = [
|
|
|
|
4001 # ipfs
|
|
|
|
];
|
2021-01-15 03:36:41 +00:00
|
|
|
firewall.allowedUDPPorts = [
|
|
|
|
4001 # ipfs
|
|
|
|
];
|
2020-05-05 23:28:23 +00:00
|
|
|
};
|
2020-11-01 18:25:01 +00:00
|
|
|
my.ip.tailscale = "100.75.142.119";
|
2022-09-01 23:22:16 +00:00
|
|
|
my.ip.tailscale6 = "fd7a:115c:a1e0:ab12:4843:cd96:624b:8e77";
|
2022-01-01 09:03:25 +00:00
|
|
|
my.coredns.bind = [ "enp1s0" "tailscale0" "127.0.0.1" "::1" ];
|
2020-05-05 23:28:23 +00:00
|
|
|
|
|
|
|
# Define a user account.
|
|
|
|
users.mutableUsers = false;
|
|
|
|
users.users = {
|
2020-05-31 20:27:23 +00:00
|
|
|
sonarr.extraGroups = [ "deluge" "content" ];
|
|
|
|
radarr.extraGroups = [ "deluge" "content" ];
|
2020-09-30 17:39:34 +00:00
|
|
|
} // (lib.setAttrByPath [ config.services.nginx.user "extraGroups" ] [ "acme" ]);
|
2020-05-05 23:28:23 +00:00
|
|
|
|
|
|
|
services.openssh.hostKeys = [
|
|
|
|
{
|
|
|
|
path = "/persist/etc/ssh/ssh_host_ed25519_key";
|
|
|
|
type = "ed25519";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
path = "/persist/etc/ssh/ssh_host_rsa_key";
|
|
|
|
type = "rsa";
|
|
|
|
bits = 4096;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2020-05-31 20:27:23 +00:00
|
|
|
services.sonarr = {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
services.radarr = {
|
|
|
|
enable = true;
|
|
|
|
};
|
2020-05-09 10:14:37 +00:00
|
|
|
|
2020-05-31 22:28:01 +00:00
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
2020-05-31 22:53:39 +00:00
|
|
|
virtualHosts = vhosts;
|
2020-05-31 22:28:01 +00:00
|
|
|
};
|
|
|
|
|
2022-10-08 20:20:04 +00:00
|
|
|
services.kubo = {
|
2021-01-15 00:58:36 +00:00
|
|
|
enable = true;
|
2022-10-31 21:41:42 +00:00
|
|
|
settings = {
|
2021-01-15 00:58:36 +00:00
|
|
|
Discovery.MDNS.Enabled = false;
|
|
|
|
Swarm.DisableNatPortMap = true;
|
2021-01-26 11:40:36 +00:00
|
|
|
Experimental.FilestoreEnabled = true;
|
2021-01-15 00:58:36 +00:00
|
|
|
};
|
|
|
|
dataDir = "/store/ipfs";
|
|
|
|
};
|
|
|
|
|
2020-11-29 02:31:29 +00:00
|
|
|
system.stateVersion = "20.09";
|
2020-09-30 17:39:34 +00:00
|
|
|
}
|