2023-05-27 16:57:28 +01:00
|
|
|
{ lib, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib.my) net;
|
2023-11-02 13:41:50 +00:00
|
|
|
inherit (lib.my.c.colony) domain prefixes;
|
2023-05-27 16:57:28 +01:00
|
|
|
in
|
|
|
|
{
|
2022-05-29 03:30:40 +01:00
|
|
|
imports = [ ./containers ];
|
|
|
|
|
|
|
|
nixos.systems.shill = {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
nixpkgs = "mine";
|
|
|
|
|
|
|
|
assignments = {
|
2022-11-21 01:21:50 +00:00
|
|
|
routing = {
|
|
|
|
name = "shill-vm-routing";
|
2023-05-27 16:57:28 +01:00
|
|
|
inherit domain;
|
|
|
|
ipv4.address = net.cidr.host 2 prefixes.vms.v4;
|
2022-11-21 01:21:50 +00:00
|
|
|
};
|
2022-05-29 03:30:40 +01:00
|
|
|
internal = {
|
|
|
|
name = "shill-vm";
|
|
|
|
altNames = [ "ctr" ];
|
2023-05-27 16:57:28 +01:00
|
|
|
inherit domain;
|
2022-11-21 01:21:50 +00:00
|
|
|
ipv4 = {
|
2023-05-27 16:57:28 +01:00
|
|
|
address = net.cidr.host 1 prefixes.vip1;
|
2022-11-21 01:21:50 +00:00
|
|
|
mask = 32;
|
|
|
|
gateway = null;
|
|
|
|
genPTR = false;
|
|
|
|
};
|
2022-05-31 21:58:29 +01:00
|
|
|
ipv6 = {
|
2022-05-29 03:30:40 +01:00
|
|
|
iid = "::2";
|
2023-05-27 16:57:28 +01:00
|
|
|
address = net.cidr.host 2 prefixes.vms.v6;
|
2022-05-29 03:30:40 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
ctrs = {
|
2022-06-10 20:42:13 +01:00
|
|
|
name = "shill-vm-ctrs";
|
2023-05-27 16:57:28 +01:00
|
|
|
inherit domain;
|
2022-05-29 03:30:40 +01:00
|
|
|
ipv4 = {
|
2023-05-27 16:57:28 +01:00
|
|
|
address = net.cidr.host 1 prefixes.ctrs.v4;
|
2022-05-29 03:30:40 +01:00
|
|
|
gateway = null;
|
|
|
|
};
|
2023-05-27 16:57:28 +01:00
|
|
|
ipv6.address = net.cidr.host 1 prefixes.ctrs.v6;
|
2022-05-29 03:30:40 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
configuration = { lib, pkgs, modulesPath, config, assignments, allAssignments, ... }:
|
|
|
|
let
|
2022-05-31 21:25:51 +01:00
|
|
|
inherit (builtins) mapAttrs;
|
2022-06-11 19:13:20 +01:00
|
|
|
inherit (lib) mkIf mkMerge mkForce;
|
2022-05-29 03:30:40 +01:00
|
|
|
inherit (lib.my) networkdAssignment;
|
|
|
|
in
|
|
|
|
{
|
2023-11-16 22:00:49 +00:00
|
|
|
imports = [ "${modulesPath}/profiles/qemu-guest.nix" ./gitea.nix ];
|
2022-05-29 03:30:40 +01:00
|
|
|
|
|
|
|
config = mkMerge [
|
|
|
|
{
|
2022-06-12 02:40:57 +01:00
|
|
|
boot = {
|
|
|
|
kernelParams = [ "console=ttyS0,115200n8" ];
|
|
|
|
# Stolen from nixos/modules/services/torrent/transmission.nix
|
|
|
|
kernel.sysctl = {
|
2022-11-20 04:44:22 +00:00
|
|
|
"net.core.rmem_max" = 4194304; # 4MB
|
|
|
|
"net.core.wmem_max" = 1048576; # 1MB
|
2022-06-12 02:40:57 +01:00
|
|
|
"net.ipv4.ip_local_port_range" = "16384 65535";
|
2022-07-10 18:16:51 +01:00
|
|
|
#"net.netfilter.nf_conntrack_generic_timeout" = 60;
|
|
|
|
#"net.netfilter.nf_conntrack_tcp_timeout_established" = 600;
|
|
|
|
#"net.netfilter.nf_conntrack_tcp_timeout_time_wait" = 1;
|
2022-06-12 02:40:57 +01:00
|
|
|
"net.netfilter.nf_conntrack_max" = 1048576;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-05-29 03:30:40 +01:00
|
|
|
fileSystems = {
|
|
|
|
"/boot" = {
|
|
|
|
device = "/dev/disk/by-label/ESP";
|
|
|
|
fsType = "vfat";
|
|
|
|
};
|
|
|
|
"/nix" = {
|
2022-06-06 15:53:57 +01:00
|
|
|
device = "/dev/disk/by-label/nix";
|
2022-05-29 03:30:40 +01:00
|
|
|
fsType = "ext4";
|
|
|
|
};
|
|
|
|
"/persist" = {
|
2022-06-06 15:53:57 +01:00
|
|
|
device = "/dev/disk/by-label/persist";
|
2022-05-29 03:30:40 +01:00
|
|
|
fsType = "ext4";
|
|
|
|
neededForBoot = true;
|
|
|
|
};
|
2023-11-17 22:14:19 +00:00
|
|
|
|
2023-02-21 14:22:10 +00:00
|
|
|
"/mnt/media" = {
|
|
|
|
device = "/dev/disk/by-label/media";
|
|
|
|
fsType = "ext4";
|
|
|
|
};
|
2022-07-16 15:01:15 +01:00
|
|
|
"/mnt/minio" = {
|
|
|
|
device = "/dev/disk/by-label/minio";
|
|
|
|
fsType = "xfs";
|
|
|
|
};
|
2023-11-17 22:14:19 +00:00
|
|
|
"/mnt/atticd" = {
|
|
|
|
device = "/dev/disk/by-label/atticd";
|
|
|
|
fsType = "ext4";
|
|
|
|
};
|
2022-05-29 03:30:40 +01:00
|
|
|
};
|
|
|
|
|
2022-07-16 21:33:07 +01:00
|
|
|
nix.settings = {
|
|
|
|
# Exclude S3 cache that we're right next to
|
|
|
|
substituters = mkForce [ "https://cache.nixos.org" ];
|
|
|
|
};
|
|
|
|
|
2022-06-12 17:27:11 +01:00
|
|
|
services = {
|
2023-11-02 13:41:50 +00:00
|
|
|
fstrim = lib.my.c.colony.fstrimConfig;
|
2022-06-12 17:27:11 +01:00
|
|
|
netdata.enable = true;
|
|
|
|
};
|
|
|
|
|
2022-05-29 03:30:40 +01:00
|
|
|
systemd.network = {
|
|
|
|
links = {
|
|
|
|
"10-vms" = {
|
2022-06-18 02:56:05 +01:00
|
|
|
matchConfig.MACAddress = "52:54:00:27:3d:5c";
|
2022-05-29 03:30:40 +01:00
|
|
|
linkConfig.Name = "vms";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
netdevs."25-ctrs".netdevConfig = {
|
|
|
|
Name = "ctrs";
|
|
|
|
Kind = "bridge";
|
|
|
|
};
|
|
|
|
|
|
|
|
networks = {
|
2022-11-21 01:21:50 +00:00
|
|
|
"80-vms" = mkMerge [
|
|
|
|
(networkdAssignment "vms" assignments.routing)
|
|
|
|
(networkdAssignment "vms" assignments.internal)
|
|
|
|
];
|
2022-05-29 03:30:40 +01:00
|
|
|
"80-ctrs" = mkMerge [
|
|
|
|
(networkdAssignment "ctrs" assignments.ctrs)
|
|
|
|
{
|
|
|
|
networkConfig = {
|
|
|
|
IPv6AcceptRA = mkForce false;
|
|
|
|
IPv6SendRA = true;
|
|
|
|
};
|
|
|
|
ipv6SendRAConfig = {
|
2022-05-29 15:48:26 +01:00
|
|
|
DNS = [ allAssignments.estuary.base.ipv6.address ];
|
2022-05-29 03:30:40 +01:00
|
|
|
Domains = [ config.networking.domain ];
|
|
|
|
};
|
|
|
|
ipv6Prefixes = [
|
|
|
|
{
|
2023-11-02 13:41:50 +00:00
|
|
|
ipv6PrefixConfig.Prefix = prefixes.ctrs.v6;
|
2022-05-29 03:30:40 +01:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
my = {
|
2022-06-18 02:56:05 +01:00
|
|
|
secrets.key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ6bc1pQCYalLXdB4X+7kFXtkTdFalbH5rchjuYj2ceU";
|
2022-05-29 03:30:40 +01:00
|
|
|
server.enable = true;
|
|
|
|
|
|
|
|
firewall = {
|
2022-06-12 17:27:11 +01:00
|
|
|
tcp.allowed = [ 19999 ];
|
2022-06-12 17:33:33 +01:00
|
|
|
trustedInterfaces = [ "ctrs" ];
|
|
|
|
extraRules = ''
|
|
|
|
table inet filter {
|
|
|
|
chain forward {
|
|
|
|
# Trust that the outer firewall has done the filtering!
|
|
|
|
iifname vms oifname ctrs accept
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
2022-05-29 03:30:40 +01:00
|
|
|
};
|
|
|
|
|
2022-06-11 19:13:20 +01:00
|
|
|
containers.instances =
|
|
|
|
let
|
|
|
|
instances = {
|
2023-06-24 17:31:11 +01:00
|
|
|
middleman = {
|
|
|
|
bindMounts = {
|
|
|
|
"/mnt/media" = {};
|
|
|
|
};
|
|
|
|
};
|
2022-06-11 19:13:20 +01:00
|
|
|
vaultwarden = {};
|
|
|
|
colony-psql = {};
|
|
|
|
chatterbox = {};
|
|
|
|
jackflix = {
|
|
|
|
bindMounts = {
|
|
|
|
"/mnt/media".readOnly = false;
|
|
|
|
};
|
|
|
|
};
|
2022-07-16 15:01:15 +01:00
|
|
|
object = {
|
|
|
|
bindMounts = {
|
|
|
|
"/mnt/minio".readOnly = false;
|
2023-11-17 22:14:19 +00:00
|
|
|
"/mnt/atticd".readOnly = false;
|
2022-07-16 15:01:15 +01:00
|
|
|
};
|
|
|
|
};
|
2022-11-20 02:43:48 +00:00
|
|
|
toot = {};
|
2022-06-11 19:13:20 +01:00
|
|
|
};
|
|
|
|
in
|
|
|
|
mkMerge [
|
|
|
|
instances
|
|
|
|
(mapAttrs (n: i: {
|
|
|
|
networking.bridge = "ctrs";
|
|
|
|
}) instances)
|
|
|
|
];
|
2022-05-29 03:30:40 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|