2021-04-11 22:50:30 +02:00
|
|
|
{ depot, lib, pkgs, ... }: # readTree options
|
2021-04-11 21:57:00 +02:00
|
|
|
{ config, ... }: # passed by module system
|
2020-07-02 20:19:08 +02:00
|
|
|
|
|
|
|
let
|
2020-07-02 21:27:02 +02:00
|
|
|
inherit (builtins) listToAttrs;
|
|
|
|
inherit (lib) range;
|
2022-05-26 14:33:44 +02:00
|
|
|
|
|
|
|
mod = name: depot.path.origSrc + ("/ops/modules/" + name);
|
2022-01-30 17:06:58 +01:00
|
|
|
in
|
|
|
|
{
|
2020-07-02 20:19:08 +02:00
|
|
|
imports = [
|
2022-05-26 14:33:44 +02:00
|
|
|
(mod "atward.nix")
|
2022-06-22 18:24:35 +02:00
|
|
|
(mod "cgit.nix")
|
2022-05-26 14:33:44 +02:00
|
|
|
(mod "clbot.nix")
|
2023-11-27 09:44:06 +01:00
|
|
|
(mod "gerrit-autosubmit.nix")
|
2022-05-26 14:33:44 +02:00
|
|
|
(mod "irccat.nix")
|
|
|
|
(mod "josh.nix")
|
|
|
|
(mod "journaldriver.nix")
|
|
|
|
(mod "known-hosts.nix")
|
2024-02-17 06:48:12 +01:00
|
|
|
(mod "livegrep.nix")
|
2022-05-26 14:33:44 +02:00
|
|
|
(mod "monorepo-gerrit.nix")
|
|
|
|
(mod "owothia.nix")
|
|
|
|
(mod "panettone.nix")
|
|
|
|
(mod "paroxysm.nix")
|
|
|
|
(mod "restic.nix")
|
|
|
|
(mod "smtprelay.nix")
|
|
|
|
(mod "sourcegraph.nix")
|
2024-05-26 20:54:55 +02:00
|
|
|
(mod "teleirc.nix")
|
2022-05-26 14:33:44 +02:00
|
|
|
(mod "tvl-buildkite.nix")
|
|
|
|
(mod "tvl-slapd/default.nix")
|
|
|
|
(mod "tvl-users.nix")
|
|
|
|
(mod "www/atward.tvl.fyi.nix")
|
|
|
|
(mod "www/auth.tvl.fyi.nix")
|
|
|
|
(mod "www/b.tvl.fyi.nix")
|
|
|
|
(mod "www/cache.tvl.su.nix")
|
|
|
|
(mod "www/cl.tvl.fyi.nix")
|
|
|
|
(mod "www/code.tvl.fyi.nix")
|
|
|
|
(mod "www/cs.tvl.fyi.nix")
|
|
|
|
(mod "www/deploys.tvl.fyi.nix")
|
|
|
|
(mod "www/self-redirect.nix")
|
2023-09-05 00:19:55 +02:00
|
|
|
(mod "www/signup.tvl.fyi.nix")
|
2022-05-26 14:33:44 +02:00
|
|
|
(mod "www/static.tvl.fyi.nix")
|
2022-11-06 19:51:46 +01:00
|
|
|
(mod "www/status.tvl.su.nix")
|
2022-05-26 14:33:44 +02:00
|
|
|
(mod "www/todo.tvl.fyi.nix")
|
2023-03-14 20:27:30 +01:00
|
|
|
(mod "www/tvix.dev.nix")
|
2022-05-26 14:33:44 +02:00
|
|
|
(mod "www/tvl.fyi.nix")
|
|
|
|
(mod "www/tvl.su.nix")
|
|
|
|
(mod "www/wigglydonke.rs.nix")
|
|
|
|
|
2023-10-08 22:31:10 +02:00
|
|
|
# experimental!
|
|
|
|
(mod "www/grep.tvl.fyi.nix")
|
|
|
|
|
2022-05-26 14:33:44 +02:00
|
|
|
(depot.third_party.agenix.src + "/modules/age.nix")
|
2020-07-02 20:19:08 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
hardware = {
|
|
|
|
enableRedistributableFirmware = true;
|
|
|
|
cpu.amd.updateMicrocode = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
boot = {
|
2023-04-26 12:30:34 +02:00
|
|
|
tmp.useTmpfs = true;
|
2020-07-02 20:19:08 +02:00
|
|
|
kernelModules = [ "kvm-amd" ];
|
|
|
|
supportedFilesystems = [ "zfs" ];
|
|
|
|
|
|
|
|
initrd = {
|
|
|
|
availableKernelModules = [
|
2022-01-30 17:06:58 +01:00
|
|
|
"igb"
|
|
|
|
"xhci_pci"
|
|
|
|
"nvme"
|
|
|
|
"ahci"
|
|
|
|
"usbhid"
|
|
|
|
"usb_storage"
|
|
|
|
"sr_mod"
|
2020-07-02 20:19:08 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
# Enable SSH in the initrd so that we can enter disk encryption
|
|
|
|
# passwords remotely.
|
|
|
|
network = {
|
|
|
|
enable = true;
|
|
|
|
ssh = {
|
|
|
|
enable = true;
|
|
|
|
port = 2222;
|
2020-12-20 18:06:09 +01:00
|
|
|
authorizedKeys =
|
|
|
|
depot.users.tazjin.keys.all
|
|
|
|
++ depot.users.lukegb.keys.all
|
2024-02-12 04:00:40 +01:00
|
|
|
++ [ depot.users.aspen.keys.whitby ];
|
2020-07-02 20:19:08 +02:00
|
|
|
|
|
|
|
hostKeys = [
|
|
|
|
/etc/secrets/initrd_host_ed25519_key
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
# this will launch the zfs password prompt on login and kill the
|
|
|
|
# other prompt
|
|
|
|
postCommands = ''
|
|
|
|
echo "zfs load-key -a && killall zfs" >> /root/.profile
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-03-26 00:44:08 +01:00
|
|
|
kernel.sysctl = {
|
|
|
|
"net.ipv4.tcp_congestion_control" = "bbr";
|
|
|
|
};
|
|
|
|
|
2020-07-02 20:19:08 +02:00
|
|
|
loader.grub = {
|
|
|
|
enable = true;
|
|
|
|
efiSupport = true;
|
|
|
|
efiInstallAsRemovable = true;
|
|
|
|
device = "/dev/disk/by-id/nvme-SAMSUNG_MZQLB1T9HAJR-00007_S439NA0N201620";
|
|
|
|
};
|
|
|
|
|
|
|
|
zfs.requestEncryptionCredentials = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
fileSystems = {
|
|
|
|
"/" = {
|
|
|
|
device = "zroot/root";
|
|
|
|
fsType = "zfs";
|
|
|
|
};
|
|
|
|
|
|
|
|
"/boot" = {
|
|
|
|
device = "/dev/disk/by-uuid/073E-7FBD";
|
|
|
|
fsType = "vfat";
|
|
|
|
};
|
|
|
|
|
|
|
|
"/nix" = {
|
|
|
|
device = "zroot/nix";
|
|
|
|
fsType = "zfs";
|
|
|
|
};
|
|
|
|
|
|
|
|
"/home" = {
|
|
|
|
device = "zroot/home";
|
|
|
|
fsType = "zfs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
# Glass is boring, but Luke doesn't like Wapping - the Prospect of
|
|
|
|
# Whitby, however, is quite a pleasant establishment.
|
|
|
|
hostName = "whitby";
|
2020-07-18 00:25:20 +02:00
|
|
|
domain = "tvl.fyi";
|
2020-07-02 20:19:08 +02:00
|
|
|
hostId = "b38ca543";
|
|
|
|
useDHCP = false;
|
2020-07-02 21:27:23 +02:00
|
|
|
|
2020-07-18 00:25:20 +02:00
|
|
|
# Don't use Hetzner's DNS servers.
|
|
|
|
nameservers = [
|
|
|
|
"8.8.8.8"
|
|
|
|
"8.8.4.4"
|
|
|
|
];
|
|
|
|
|
2020-07-02 21:27:23 +02:00
|
|
|
defaultGateway6 = {
|
|
|
|
address = "fe80::1";
|
|
|
|
interface = "enp196s0";
|
|
|
|
};
|
2020-07-02 20:19:08 +02:00
|
|
|
|
2021-05-21 13:11:46 +02:00
|
|
|
firewall.allowedTCPPorts = [ 22 80 443 4238 8443 29418 ];
|
|
|
|
firewall.allowedUDPPorts = [ 8443 ];
|
2020-07-02 20:19:08 +02:00
|
|
|
|
|
|
|
interfaces.enp196s0.useDHCP = true;
|
|
|
|
interfaces.enp196s0.ipv6.addresses = [
|
|
|
|
{
|
|
|
|
address = "2a01:04f8:0242:5b21::feed:edef:beef";
|
|
|
|
prefixLength = 64;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2020-07-18 00:25:20 +02:00
|
|
|
# Generate an immutable /etc/resolv.conf from the nameserver settings
|
|
|
|
# above (otherwise DHCP overwrites it):
|
|
|
|
environment.etc."resolv.conf" = with lib; {
|
2021-04-10 18:05:16 +02:00
|
|
|
source = pkgs.writeText "resolv.conf" ''
|
2021-04-12 17:59:51 +02:00
|
|
|
${concatStringsSep "\n" (map (ns: "nameserver ${ns}") config.networking.nameservers)}
|
2020-07-18 00:25:20 +02:00
|
|
|
options edns0
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-12-20 17:55:38 +01:00
|
|
|
# Disable background git gc system-wide, as it has a tendency to break CI.
|
2021-04-10 18:05:16 +02:00
|
|
|
environment.etc."gitconfig".source = pkgs.writeText "gitconfig" ''
|
2020-12-20 17:55:38 +01:00
|
|
|
[gc]
|
|
|
|
autoDetach = false
|
|
|
|
'';
|
|
|
|
|
2020-07-02 20:19:08 +02:00
|
|
|
time.timeZone = "UTC";
|
|
|
|
|
|
|
|
nix = {
|
2020-12-26 15:23:26 +01:00
|
|
|
nrBuildUsers = 256;
|
2022-08-25 14:54:32 +02:00
|
|
|
settings = {
|
|
|
|
max-jobs = lib.mkDefault 64;
|
|
|
|
secret-key-files = "/run/agenix/nix-cache-priv";
|
|
|
|
|
|
|
|
trusted-users = [
|
2024-02-12 04:00:40 +01:00
|
|
|
"aspen"
|
2022-08-25 14:54:32 +02:00
|
|
|
"lukegb"
|
|
|
|
"tazjin"
|
|
|
|
"sterni"
|
|
|
|
];
|
|
|
|
};
|
2020-07-03 16:22:21 +02:00
|
|
|
|
|
|
|
sshServe = {
|
|
|
|
enable = true;
|
|
|
|
keys = with depot.users;
|
|
|
|
tazjin.keys.all
|
|
|
|
++ lukegb.keys.all
|
2024-02-12 04:00:40 +01:00
|
|
|
++ [ aspen.keys.whitby ]
|
2021-03-25 20:59:31 +01:00
|
|
|
++ sterni.keys.all
|
2022-01-30 17:06:58 +01:00
|
|
|
;
|
2020-07-03 16:22:21 +02:00
|
|
|
};
|
2020-07-02 20:19:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
programs.mtr.enable = true;
|
2020-08-14 20:17:33 +02:00
|
|
|
programs.mosh.enable = true;
|
2020-08-13 00:15:35 +02:00
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
2023-03-30 18:22:17 +02:00
|
|
|
settings = {
|
|
|
|
PasswordAuthentication = false;
|
|
|
|
KbdInteractiveAuthentication = false;
|
|
|
|
};
|
2020-08-13 00:15:35 +02:00
|
|
|
};
|
2020-07-02 20:19:08 +02:00
|
|
|
|
2021-12-09 14:53:22 +01:00
|
|
|
# Configure secrets for services that need them.
|
2021-12-10 07:58:16 +01:00
|
|
|
age.secrets =
|
|
|
|
let
|
2021-12-12 09:14:50 +01:00
|
|
|
secretFile = name: depot.ops.secrets."${name}.age";
|
2022-01-30 17:06:58 +01:00
|
|
|
in
|
|
|
|
{
|
2021-12-10 07:58:16 +01:00
|
|
|
clbot.file = secretFile "clbot";
|
2023-11-27 09:44:06 +01:00
|
|
|
gerrit-autosubmit.file = secretFile "gerrit-autosubmit";
|
2021-12-10 13:55:08 +01:00
|
|
|
grafana.file = secretFile "grafana";
|
2021-12-10 15:10:50 +01:00
|
|
|
irccat.file = secretFile "irccat";
|
2021-12-25 15:06:15 +01:00
|
|
|
keycloak-db.file = secretFile "keycloak-db";
|
2021-12-10 19:23:05 +01:00
|
|
|
nix-cache-priv.file = secretFile "nix-cache-priv";
|
2021-12-10 21:19:56 +01:00
|
|
|
owothia.file = secretFile "owothia";
|
|
|
|
panettone.file = secretFile "panettone";
|
2022-01-01 14:38:14 +01:00
|
|
|
smtprelay.file = secretFile "smtprelay";
|
2024-05-26 20:54:55 +02:00
|
|
|
teleirc.file = secretFile "teleirc";
|
2021-12-10 08:29:41 +01:00
|
|
|
|
|
|
|
buildkite-agent-token = {
|
|
|
|
file = secretFile "buildkite-agent-token";
|
|
|
|
mode = "0440";
|
|
|
|
group = "buildkite-agents";
|
|
|
|
};
|
2021-12-10 13:32:11 +01:00
|
|
|
|
2021-12-10 14:11:19 +01:00
|
|
|
buildkite-graphql-token = {
|
|
|
|
file = secretFile "buildkite-graphql-token";
|
|
|
|
mode = "0440";
|
2021-12-10 21:01:20 +01:00
|
|
|
group = "buildkite-agents";
|
2021-12-10 14:11:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
buildkite-besadii-config = {
|
|
|
|
file = secretFile "besadii";
|
|
|
|
mode = "0440";
|
2021-12-10 21:01:20 +01:00
|
|
|
group = "buildkite-agents";
|
2021-12-10 14:11:19 +01:00
|
|
|
};
|
|
|
|
|
2022-05-25 18:17:25 +02:00
|
|
|
buildkite-private-key = {
|
|
|
|
file = secretFile "buildkite-ssh-private-key";
|
|
|
|
mode = "0440";
|
|
|
|
group = "buildkite-agents";
|
|
|
|
};
|
|
|
|
|
2021-12-10 14:11:19 +01:00
|
|
|
gerrit-besadii-config = {
|
|
|
|
file = secretFile "besadii";
|
|
|
|
owner = "git";
|
|
|
|
};
|
|
|
|
|
2021-12-25 22:03:41 +01:00
|
|
|
gerrit-secrets = {
|
|
|
|
file = secretFile "gerrit-secrets";
|
|
|
|
path = "/var/lib/gerrit/etc/secure.config";
|
|
|
|
owner = "git";
|
|
|
|
mode = "0400";
|
|
|
|
};
|
|
|
|
|
2021-12-10 13:32:11 +01:00
|
|
|
clbot-ssh = {
|
|
|
|
file = secretFile "clbot-ssh";
|
|
|
|
owner = "clbot";
|
|
|
|
};
|
2021-12-10 19:23:05 +01:00
|
|
|
|
|
|
|
# Not actually a secret
|
|
|
|
nix-cache-pub = {
|
|
|
|
file = secretFile "nix-cache-pub";
|
|
|
|
mode = "0444";
|
|
|
|
};
|
2022-07-03 14:28:51 +02:00
|
|
|
|
|
|
|
depot-replica-key = {
|
|
|
|
file = secretFile "depot-replica-key";
|
|
|
|
mode = "0500";
|
|
|
|
owner = "git";
|
|
|
|
group = "git";
|
|
|
|
path = "/var/lib/git/.ssh/id_ed25519";
|
|
|
|
};
|
2021-12-10 07:58:16 +01:00
|
|
|
};
|
2021-12-09 14:53:22 +01:00
|
|
|
|
2021-04-14 18:16:42 +02:00
|
|
|
# Automatically collect garbage from the Nix store.
|
|
|
|
services.depot.automatic-gc = {
|
|
|
|
enable = true;
|
|
|
|
interval = "1 hour";
|
|
|
|
diskThreshold = 200; # GiB
|
|
|
|
maxFreed = 420; # GiB
|
|
|
|
preserveGenerations = "90d";
|
|
|
|
};
|
|
|
|
|
2020-07-02 21:27:02 +02:00
|
|
|
# Run a handful of Buildkite agents to support parallel builds.
|
2021-04-09 19:04:50 +02:00
|
|
|
services.depot.buildkite = {
|
|
|
|
enable = true;
|
|
|
|
agentCount = 32;
|
|
|
|
};
|
2020-07-02 21:27:02 +02:00
|
|
|
|
2020-07-11 13:51:04 +02:00
|
|
|
# Start a local SMTP relay to Gmail (used by gerrit)
|
|
|
|
services.depot.smtprelay = {
|
|
|
|
enable = true;
|
|
|
|
args = {
|
|
|
|
listen = ":2525";
|
|
|
|
remote_host = "smtp.gmail.com:587";
|
|
|
|
remote_auth = "plain";
|
|
|
|
remote_user = "tvlbot@tazj.in";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-05-21 01:09:14 +02:00
|
|
|
# Start a ZNC instance which bounces for tvlbot and owothia.
|
|
|
|
services.znc = {
|
|
|
|
enable = true;
|
|
|
|
useLegacyConfig = false;
|
|
|
|
config = {
|
|
|
|
LoadModule = [
|
|
|
|
"webadmin"
|
|
|
|
"adminlog"
|
|
|
|
];
|
|
|
|
|
|
|
|
User.admin = {
|
|
|
|
Admin = true;
|
|
|
|
Pass.password = {
|
|
|
|
Method = "sha256";
|
|
|
|
Hash = "bb00aa8239de484c2925b1c3f6a196fb7612633f001daa9b674f83abe7e1103f";
|
|
|
|
Salt = "TiB0Ochb1CrtpMTl;2;j";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
Listener.l = {
|
|
|
|
Host = "localhost";
|
|
|
|
Port = 2627; # bncr
|
|
|
|
SSL = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-07-11 14:03:34 +02:00
|
|
|
# Start the Gerrit->IRC bot
|
|
|
|
services.depot.clbot = {
|
|
|
|
enable = true;
|
2024-05-13 17:54:34 +02:00
|
|
|
channels = {
|
|
|
|
"#tvl" = { };
|
|
|
|
"#tvix-dev" = {
|
|
|
|
only_display = "tvix,nix-compat,third_party,third-party,3p";
|
|
|
|
};
|
|
|
|
};
|
2020-07-11 14:03:34 +02:00
|
|
|
|
2021-05-22 15:22:03 +02:00
|
|
|
# See //fun/clbot for details.
|
2020-07-11 14:03:34 +02:00
|
|
|
flags = {
|
|
|
|
gerrit_host = "cl.tvl.fyi:29418";
|
|
|
|
gerrit_ssh_auth_username = "clbot";
|
2022-05-22 23:51:49 +02:00
|
|
|
gerrit_ssh_auth_key = config.age.secretsDir + "/clbot-ssh";
|
2021-05-22 15:22:03 +02:00
|
|
|
|
|
|
|
irc_server = "localhost:${toString config.services.znc.config.Listener.l.Port}";
|
|
|
|
irc_user = "tvlbot";
|
|
|
|
irc_nick = "tvlbot";
|
2020-07-11 14:03:34 +02:00
|
|
|
|
|
|
|
notify_branches = "canon,refs/meta/config";
|
|
|
|
notify_repo = "depot";
|
|
|
|
|
|
|
|
# This secret is read from an environment variable, which is
|
2021-12-10 13:32:11 +01:00
|
|
|
# populated by a systemd EnvironmentFile.
|
2020-07-11 14:03:34 +02:00
|
|
|
irc_pass = "$CLBOT_PASS";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-07-22 01:40:49 +02:00
|
|
|
services.depot = {
|
|
|
|
# Run a SourceGraph code search instance
|
|
|
|
sourcegraph.enable = true;
|
|
|
|
|
2024-02-17 06:48:12 +01:00
|
|
|
# Run a livegrep code search instance
|
|
|
|
livegrep.enable = true;
|
|
|
|
|
2020-07-22 01:40:49 +02:00
|
|
|
# Run the Panettone issue tracker
|
2020-07-26 21:41:15 +02:00
|
|
|
panettone = {
|
|
|
|
enable = true;
|
|
|
|
dbUser = "panettone";
|
|
|
|
dbName = "panettone";
|
2021-05-22 17:05:45 +02:00
|
|
|
irccatChannel = "#tvl";
|
2020-07-26 21:41:15 +02:00
|
|
|
};
|
2020-07-31 23:30:52 +02:00
|
|
|
|
|
|
|
# Run the first cursed bot (quote bot)
|
|
|
|
paroxysm.enable = true;
|
2020-11-08 03:16:16 +01:00
|
|
|
|
2021-05-22 15:44:44 +02:00
|
|
|
# Run the second cursed bot
|
|
|
|
owothia = {
|
|
|
|
enable = true;
|
|
|
|
ircServer = "localhost";
|
|
|
|
ircPort = config.services.znc.config.Listener.l.Port;
|
|
|
|
};
|
|
|
|
|
2020-11-08 03:16:16 +01:00
|
|
|
# Run irccat to forward messages to IRC
|
|
|
|
irccat = {
|
|
|
|
enable = true;
|
|
|
|
config = {
|
|
|
|
tcp.listen = ":4722"; # "ircc"
|
|
|
|
irc = {
|
2021-05-22 17:05:45 +02:00
|
|
|
server = "localhost:${toString config.services.znc.config.Listener.l.Port}";
|
|
|
|
tls = false;
|
2020-11-08 03:16:16 +01:00
|
|
|
nick = "tvlbot";
|
2021-05-23 22:30:23 +02:00
|
|
|
# Note: irccat means 'ident' where it says 'realname', so
|
|
|
|
# this is critical for connecting to ZNC.
|
|
|
|
realname = "tvlbot";
|
2020-11-08 03:16:16 +01:00
|
|
|
channels = [
|
2021-05-22 17:05:45 +02:00
|
|
|
"#tvl"
|
2020-11-08 03:16:16 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2021-05-04 00:43:08 +02:00
|
|
|
|
2024-05-26 20:54:55 +02:00
|
|
|
# Run the Telegram<>IRC bridge for Volga Sprint.
|
|
|
|
teleirc.enable = true;
|
|
|
|
|
2021-05-04 00:43:08 +02:00
|
|
|
# Run atward, the search engine redirection thing.
|
|
|
|
atward.enable = true;
|
2021-08-06 13:53:41 +02:00
|
|
|
|
2021-09-16 17:46:17 +02:00
|
|
|
# Run cgit & josh to serve git
|
2022-07-11 13:15:14 +02:00
|
|
|
cgit = {
|
|
|
|
enable = true;
|
|
|
|
user = "git"; # run as the same user as gerrit
|
|
|
|
};
|
|
|
|
|
2022-02-16 19:34:18 +01:00
|
|
|
josh.enable = true;
|
2021-09-16 20:47:25 +02:00
|
|
|
|
2021-11-20 17:32:11 +01:00
|
|
|
# Configure backups to GleSYS
|
2021-09-16 20:47:25 +02:00
|
|
|
restic = {
|
|
|
|
enable = true;
|
|
|
|
paths = [
|
|
|
|
"/var/backup/postgresql"
|
|
|
|
"/var/lib/grafana"
|
|
|
|
"/var/lib/znc"
|
|
|
|
];
|
|
|
|
};
|
2021-12-09 14:45:06 +01:00
|
|
|
|
|
|
|
# Run autosubmit bot for Gerrit
|
2023-11-27 09:44:06 +01:00
|
|
|
gerrit-autosubmit.enable = true;
|
2020-07-26 21:41:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
|
|
|
enableTCPIP = true;
|
2023-11-05 09:51:46 +01:00
|
|
|
package = pkgs.postgresql_16;
|
2020-07-26 21:41:15 +02:00
|
|
|
|
2020-07-28 03:30:47 +02:00
|
|
|
authentication = lib.mkForce ''
|
2020-07-26 21:41:15 +02:00
|
|
|
local all all trust
|
2020-07-28 03:30:47 +02:00
|
|
|
host all all 127.0.0.1/32 password
|
|
|
|
host all all ::1/128 password
|
|
|
|
hostnossl all all 127.0.0.1/32 password
|
|
|
|
hostnossl all all ::1/128 password
|
2020-07-26 21:41:15 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
ensureDatabases = [
|
|
|
|
"panettone"
|
|
|
|
];
|
|
|
|
|
|
|
|
ensureUsers = [{
|
|
|
|
name = "panettone";
|
2024-02-26 12:34:20 +01:00
|
|
|
ensureDBOwnership = true;
|
2020-07-26 21:41:15 +02:00
|
|
|
}];
|
2020-07-22 01:40:49 +02:00
|
|
|
};
|
2020-07-12 13:54:16 +02:00
|
|
|
|
2020-08-01 18:41:30 +02:00
|
|
|
services.postgresqlBackup = {
|
|
|
|
enable = true;
|
|
|
|
databases = [
|
2021-12-25 15:06:15 +01:00
|
|
|
"keycloak"
|
2020-08-01 18:41:30 +02:00
|
|
|
"panettone"
|
2021-12-25 15:06:15 +01:00
|
|
|
"tvldb"
|
2020-08-01 18:41:30 +02:00
|
|
|
];
|
|
|
|
};
|
2020-07-26 21:41:15 +02:00
|
|
|
|
2021-04-04 20:24:34 +02:00
|
|
|
services.nix-serve = {
|
|
|
|
enable = true;
|
|
|
|
port = 6443;
|
2022-05-22 23:51:49 +02:00
|
|
|
secretKeyFile = config.age.secretsDir + "/nix-cache-priv";
|
2021-04-04 20:24:34 +02:00
|
|
|
bindAddress = "localhost";
|
|
|
|
};
|
|
|
|
|
2021-05-23 14:03:19 +02:00
|
|
|
services.fail2ban.enable = true;
|
|
|
|
|
2022-01-13 09:15:43 +01:00
|
|
|
environment.systemPackages = (with pkgs; [
|
|
|
|
bat
|
2020-07-02 20:19:08 +02:00
|
|
|
bb
|
|
|
|
curl
|
2021-12-13 13:47:13 +01:00
|
|
|
direnv
|
2020-07-02 20:19:08 +02:00
|
|
|
emacs-nox
|
2022-01-13 09:15:43 +01:00
|
|
|
fd
|
2020-07-02 20:19:08 +02:00
|
|
|
git
|
|
|
|
htop
|
2022-01-13 09:15:43 +01:00
|
|
|
hyperfine
|
2021-12-13 13:47:13 +01:00
|
|
|
jq
|
2020-07-02 20:19:08 +02:00
|
|
|
nano
|
2022-01-13 09:15:43 +01:00
|
|
|
nvd
|
2021-12-13 13:47:13 +01:00
|
|
|
ripgrep
|
2022-01-13 09:15:43 +01:00
|
|
|
tree
|
|
|
|
unzip
|
2020-07-02 20:19:08 +02:00
|
|
|
vim
|
|
|
|
zfs
|
|
|
|
zfstools
|
2022-01-13 09:15:43 +01:00
|
|
|
]) ++ (with depot; [
|
|
|
|
ops.deploy-whitby
|
|
|
|
]);
|
2020-07-02 20:19:08 +02:00
|
|
|
|
2022-01-30 00:04:33 +01:00
|
|
|
# Required for prometheus to be able to scrape stats
|
|
|
|
services.nginx.statusPage = true;
|
|
|
|
|
2021-04-11 21:57:00 +02:00
|
|
|
# Configure Prometheus & Grafana. Exporter configuration for
|
|
|
|
# Prometheus is inside the respective service modules.
|
|
|
|
services.prometheus = {
|
|
|
|
enable = true;
|
2022-03-31 22:58:20 +02:00
|
|
|
retentionTime = "90d";
|
2021-04-11 21:57:00 +02:00
|
|
|
|
2022-01-29 23:49:47 +01:00
|
|
|
exporters = {
|
|
|
|
node = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
enabledCollectors = [
|
|
|
|
"logind"
|
|
|
|
"processes"
|
|
|
|
"systemd"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
nginx = {
|
|
|
|
enable = true;
|
|
|
|
sslVerify = false;
|
|
|
|
constLabels = [ "host=whitby" ];
|
|
|
|
};
|
2021-04-11 21:57:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
scrapeConfigs = [{
|
|
|
|
job_name = "node";
|
|
|
|
scrape_interval = "5s";
|
|
|
|
static_configs = [{
|
2022-01-30 17:06:58 +01:00
|
|
|
targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
|
2021-04-11 21:57:00 +02:00
|
|
|
}];
|
2022-01-30 17:06:58 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
job_name = "nginx";
|
|
|
|
scrape_interval = "5s";
|
|
|
|
static_configs = [{
|
|
|
|
targets = [ "localhost:${toString config.services.prometheus.exporters.nginx.port}" ];
|
|
|
|
}];
|
2022-01-29 23:49:47 +01:00
|
|
|
}];
|
2021-04-11 21:57:00 +02:00
|
|
|
};
|
|
|
|
|
2021-04-12 17:59:51 +02:00
|
|
|
services.grafana = {
|
2022-11-05 15:51:54 +01:00
|
|
|
enable = true;
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
server = {
|
|
|
|
http_port = 4723; # "graf" on phone keyboard
|
|
|
|
domain = "status.tvl.su";
|
|
|
|
root_url = "https://status.tvl.su";
|
|
|
|
};
|
|
|
|
|
|
|
|
analytics.reporting_enabled = false;
|
|
|
|
|
|
|
|
"auth.generic_oauth" = {
|
|
|
|
enabled = true;
|
|
|
|
client_id = "grafana";
|
|
|
|
scopes = "openid profile email";
|
|
|
|
name = "TVL";
|
|
|
|
email_attribute_path = "mail";
|
|
|
|
login_attribute_path = "sub";
|
|
|
|
name_attribute_path = "displayName";
|
|
|
|
auth_url = "https://auth.tvl.fyi/auth/realms/TVL/protocol/openid-connect/auth";
|
|
|
|
token_url = "https://auth.tvl.fyi/auth/realms/TVL/protocol/openid-connect/token";
|
|
|
|
api_url = "https://auth.tvl.fyi/auth/realms/TVL/protocol/openid-connect/userinfo";
|
|
|
|
|
2024-02-12 04:00:40 +01:00
|
|
|
# Give lukegb, aspen, tazjin "Admin" rights.
|
|
|
|
role_attribute_path = "((sub == 'lukegb' || sub == 'aspen' || sub == 'tazjin') && 'Admin') || 'Editor'";
|
2022-11-05 15:51:54 +01:00
|
|
|
|
|
|
|
# Allow creating new Grafana accounts from OAuth accounts.
|
|
|
|
allow_sign_up = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
"auth.anonymous" = {
|
|
|
|
enabled = true;
|
|
|
|
org_name = "The Virus Lounge";
|
|
|
|
org_role = "Viewer";
|
|
|
|
};
|
|
|
|
|
|
|
|
"auth.basic".enabled = false;
|
|
|
|
|
|
|
|
auth = {
|
|
|
|
oauth_auto_login = true;
|
|
|
|
disable_login_form = true;
|
|
|
|
};
|
|
|
|
};
|
2021-04-12 17:59:51 +02:00
|
|
|
|
|
|
|
provision = {
|
|
|
|
enable = true;
|
2022-11-05 15:51:54 +01:00
|
|
|
datasources.settings.datasources = [{
|
2021-04-12 17:59:51 +02:00
|
|
|
name = "Prometheus";
|
|
|
|
type = "prometheus";
|
|
|
|
url = "http://localhost:9090";
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
};
|
2021-12-25 15:06:15 +01:00
|
|
|
|
2021-04-13 01:32:40 +02:00
|
|
|
# Contains GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET.
|
2022-05-22 23:51:49 +02:00
|
|
|
systemd.services.grafana.serviceConfig.EnvironmentFile = config.age.secretsDir + "/grafana";
|
2021-04-12 17:59:51 +02:00
|
|
|
|
2021-12-25 15:06:15 +01:00
|
|
|
services.keycloak = {
|
|
|
|
enable = true;
|
2022-04-21 16:36:04 +02:00
|
|
|
|
|
|
|
settings = {
|
2022-10-02 15:39:37 +02:00
|
|
|
http-port = 5925; # kycl
|
2022-04-21 16:36:04 +02:00
|
|
|
hostname = "auth.tvl.fyi";
|
|
|
|
http-relative-path = "/auth";
|
|
|
|
proxy = "edge";
|
|
|
|
};
|
2021-12-25 15:06:15 +01:00
|
|
|
|
|
|
|
database = {
|
|
|
|
type = "postgresql";
|
2022-05-22 23:51:49 +02:00
|
|
|
passwordFile = config.age.secretsDir + "/keycloak-db";
|
2021-12-25 15:06:15 +01:00
|
|
|
createLocally = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
feat(ops): introduce (head|tail)scale server at net.tvl.fyi
This runs a headscale server on sanduny which lets users join their
machines to the TVL tailscale network.
This would theoretically let people communicate with each other on the
internal network, but also more notably joined servers can advertise
exit node capability so that we can have our own "VPN network", for
starters with endpoints in Germany, UK and Russia (whitby, sanduny and
koptevo respectively).
This setup isn't fully stable yet, notably:
* The IP range used by tailscale is just the default one right now,
I'm not sure if that should be changed or what.
* The system is stateful (on sanduny), but the state is not (yet)
backed up anywhere. Use with caution.
* Machine joining is a manual process requiring SSH & root access to
sanduny.
The process is to log in to sanduny, then get a headscale shell with
`sudo -u headscale bash`, and to use the `headscale` CLI within
there to administrate access.
I've opted to create a user account `tvl` for TVL-owned machines,
and a personal account for myself and my machines.
Change-Id: I4f1be1fe8062a6c2e77203ff72fe8709f4e4dec8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8837
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
2023-06-20 13:59:01 +02:00
|
|
|
# Join TVL Tailscale network at net.tvl.fyi
|
|
|
|
services.tailscale = {
|
|
|
|
enable = true;
|
|
|
|
useRoutingFeatures = "server"; # for exit-node usage
|
|
|
|
};
|
|
|
|
|
2021-12-25 15:06:15 +01:00
|
|
|
# Allow Keycloak access to the LDAP module by forcing in the JVM
|
|
|
|
# configuration
|
|
|
|
systemd.services.keycloak.environment.PREPEND_JAVA_OPTS =
|
|
|
|
"--add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED";
|
|
|
|
|
2020-07-02 23:53:59 +02:00
|
|
|
security.sudo.extraRules = [
|
|
|
|
{
|
2022-01-30 17:06:58 +01:00
|
|
|
groups = [ "wheel" ];
|
|
|
|
commands = [{ command = "ALL"; options = [ "NOPASSWD" ]; }];
|
2020-07-02 23:53:59 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2020-07-02 20:19:08 +02:00
|
|
|
users = {
|
|
|
|
# Set up a user & group for git shenanigans
|
2022-01-30 17:06:58 +01:00
|
|
|
groups.git = { };
|
2020-07-02 20:19:08 +02:00
|
|
|
users.git = {
|
|
|
|
group = "git";
|
2021-04-13 12:21:42 +02:00
|
|
|
isSystemUser = true;
|
2020-07-12 15:44:24 +02:00
|
|
|
createHome = true;
|
|
|
|
home = "/var/lib/git";
|
2020-07-02 20:19:08 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-02-10 23:48:15 +01:00
|
|
|
zramSwap.enable = true;
|
|
|
|
|
2020-07-02 20:19:08 +02:00
|
|
|
system.stateVersion = "20.03";
|
2021-04-12 17:59:51 +02:00
|
|
|
}
|