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-01-30 17:06:58 +01:00
|
|
|
in
|
|
|
|
{
|
2020-07-02 20:19:08 +02:00
|
|
|
imports = [
|
2021-05-04 00:43:08 +02:00
|
|
|
"${depot.path}/ops/modules/atward.nix"
|
2021-04-12 22:26:55 +02:00
|
|
|
"${depot.path}/ops/modules/clbot.nix"
|
2021-12-09 14:45:06 +01:00
|
|
|
"${depot.path}/ops/modules/gerrit-queue.nix"
|
2021-09-16 17:46:17 +02:00
|
|
|
"${depot.path}/ops/modules/git-serving.nix"
|
2021-04-12 22:26:55 +02:00
|
|
|
"${depot.path}/ops/modules/irccat.nix"
|
|
|
|
"${depot.path}/ops/modules/monorepo-gerrit.nix"
|
2021-08-06 13:53:41 +02:00
|
|
|
"${depot.path}/ops/modules/nixery.nix"
|
2022-01-04 12:28:58 +01:00
|
|
|
"${depot.path}/ops/modules/oauth2_proxy.nix"
|
2021-05-22 15:44:44 +02:00
|
|
|
"${depot.path}/ops/modules/owothia.nix"
|
2021-04-12 22:26:55 +02:00
|
|
|
"${depot.path}/ops/modules/panettone.nix"
|
|
|
|
"${depot.path}/ops/modules/paroxysm.nix"
|
2021-09-16 20:47:25 +02:00
|
|
|
"${depot.path}/ops/modules/restic.nix"
|
2021-04-12 22:26:55 +02:00
|
|
|
"${depot.path}/ops/modules/smtprelay.nix"
|
|
|
|
"${depot.path}/ops/modules/sourcegraph.nix"
|
|
|
|
"${depot.path}/ops/modules/tvl-buildkite.nix"
|
|
|
|
"${depot.path}/ops/modules/tvl-slapd/default.nix"
|
2021-05-04 12:55:05 +02:00
|
|
|
"${depot.path}/ops/modules/www/atward.tvl.fyi.nix"
|
2021-12-25 15:06:15 +01:00
|
|
|
"${depot.path}/ops/modules/www/auth.tvl.fyi.nix"
|
2021-04-12 22:26:55 +02:00
|
|
|
"${depot.path}/ops/modules/www/b.tvl.fyi.nix"
|
|
|
|
"${depot.path}/ops/modules/www/cache.tvl.su.nix"
|
|
|
|
"${depot.path}/ops/modules/www/cl.tvl.fyi.nix"
|
|
|
|
"${depot.path}/ops/modules/www/code.tvl.fyi.nix"
|
|
|
|
"${depot.path}/ops/modules/www/cs.tvl.fyi.nix"
|
2021-05-23 18:18:40 +02:00
|
|
|
"${depot.path}/ops/modules/www/deploys.tvl.fyi.nix"
|
2021-09-16 17:46:17 +02:00
|
|
|
"${depot.path}/ops/modules/www/images.tvl.fyi.nix"
|
2021-08-24 13:07:42 +02:00
|
|
|
"${depot.path}/ops/modules/www/nixery.dev.nix"
|
2021-10-01 18:22:20 +02:00
|
|
|
"${depot.path}/ops/modules/www/static.tvl.fyi.nix"
|
2021-04-12 17:59:51 +02:00
|
|
|
"${depot.path}/ops/modules/www/status.tvl.su.nix"
|
2021-04-12 22:26:55 +02:00
|
|
|
"${depot.path}/ops/modules/www/tazj.in.nix"
|
|
|
|
"${depot.path}/ops/modules/www/todo.tvl.fyi.nix"
|
|
|
|
"${depot.path}/ops/modules/www/tvl.fyi.nix"
|
2021-09-30 22:12:54 +02:00
|
|
|
"${depot.path}/ops/modules/www/tvl.su.nix"
|
2021-04-12 22:26:55 +02:00
|
|
|
"${depot.path}/ops/modules/www/wigglydonke.rs.nix"
|
2021-12-09 14:53:22 +01:00
|
|
|
"${depot.third_party.agenix.src}/modules/age.nix"
|
2021-04-10 18:05:16 +02:00
|
|
|
"${pkgs.path}/nixos/modules/services/web-apps/gerrit.nix"
|
2020-07-02 20:19:08 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
hardware = {
|
|
|
|
enableRedistributableFirmware = true;
|
|
|
|
cpu.amd.updateMicrocode = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
boot = {
|
|
|
|
tmpOnTmpfs = true;
|
|
|
|
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
|
2021-04-11 23:53:27 +02:00
|
|
|
++ [ depot.users.grfn.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;
|
|
|
|
version = 2;
|
|
|
|
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;
|
2020-07-02 20:19:08 +02:00
|
|
|
maxJobs = lib.mkDefault 64;
|
2020-07-02 21:07:58 +02:00
|
|
|
extraOptions = ''
|
2021-12-10 19:23:05 +01:00
|
|
|
secret-key-files = /run/agenix/nix-cache-priv
|
2020-07-02 21:07:58 +02:00
|
|
|
'';
|
2020-07-02 23:31:15 +02:00
|
|
|
|
|
|
|
trustedUsers = [
|
|
|
|
"grfn"
|
2020-07-04 22:11:30 +02:00
|
|
|
"lukegb"
|
2020-08-06 02:18:04 +02:00
|
|
|
"tazjin"
|
2021-03-25 20:59:31 +01:00
|
|
|
"sterni"
|
2020-07-02 23:31:15 +02:00
|
|
|
];
|
2020-07-03 16:22:21 +02:00
|
|
|
|
|
|
|
sshServe = {
|
|
|
|
enable = true;
|
|
|
|
keys = with depot.users;
|
|
|
|
tazjin.keys.all
|
|
|
|
++ lukegb.keys.all
|
2021-04-11 23:53:27 +02:00
|
|
|
++ [ grfn.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;
|
|
|
|
passwordAuthentication = false;
|
|
|
|
challengeResponseAuthentication = false;
|
|
|
|
};
|
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";
|
|
|
|
gerrit-queue.file = secretFile "gerrit-queue";
|
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";
|
2022-01-04 12:28:58 +01:00
|
|
|
oauth2_proxy.file = secretFile "oauth2_proxy";
|
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";
|
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
|
|
|
};
|
|
|
|
|
|
|
|
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";
|
|
|
|
};
|
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;
|
2021-05-22 15:22:03 +02:00
|
|
|
channels = [ "#tvl" ];
|
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";
|
2021-12-10 13:32:11 +01:00
|
|
|
gerrit_ssh_auth_key = "/run/agenix/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;
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
# Run atward, the search engine redirection thing.
|
|
|
|
atward.enable = true;
|
2021-08-06 13:53:41 +02:00
|
|
|
|
|
|
|
# Run a Nixery instance
|
|
|
|
nixery.enable = true;
|
2021-09-16 17:46:17 +02:00
|
|
|
|
|
|
|
# Run cgit & josh to serve git
|
|
|
|
git-serving.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
|
|
|
|
gerrit-queue.enable = true;
|
2022-01-04 12:28:58 +01:00
|
|
|
|
|
|
|
# Run oauth2_proxy for internal service auth
|
|
|
|
oauth2_proxy.enable = true;
|
2020-07-26 21:41:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
|
|
|
enableTCPIP = true;
|
|
|
|
|
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";
|
|
|
|
ensurePermissions = {
|
|
|
|
"DATABASE panettone" = "ALL PRIVILEGES";
|
|
|
|
};
|
|
|
|
}];
|
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;
|
2021-12-10 19:23:05 +01:00
|
|
|
secretKeyFile = "/run/agenix/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; [
|
|
|
|
alacritty.terminfo
|
|
|
|
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
|
|
|
|
foot.terminfo
|
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
|
2022-02-12 19:35:34 +01:00
|
|
|
# TODO(sterni): re-enable when the kitty build is fixed upstreams
|
|
|
|
# kitty.terminfo
|
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
|
2020-07-25 18:14:42 +02:00
|
|
|
rxvt_unicode.terminfo
|
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
|
|
|
|
2020-08-23 14:04:36 +02:00
|
|
|
services.journaldriver = {
|
|
|
|
enable = true;
|
|
|
|
googleCloudProject = "tvl-fyi";
|
|
|
|
logStream = "whitby";
|
|
|
|
applicationCredentials = "/var/lib/journaldriver/key.json";
|
|
|
|
};
|
|
|
|
|
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-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 = {
|
|
|
|
enable = true;
|
|
|
|
port = 4723; # "graf" on phone keyboard
|
|
|
|
domain = "status.tvl.su";
|
|
|
|
rootUrl = "https://status.tvl.su";
|
|
|
|
analytics.reporting.enable = false;
|
2022-01-30 17:06:58 +01:00
|
|
|
extraOptions =
|
|
|
|
let
|
|
|
|
options = {
|
|
|
|
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";
|
|
|
|
|
|
|
|
# Give lukegb, grfn, tazjin "Admin" rights.
|
|
|
|
role_attribute_path = "((sub == 'lukegb' || sub == 'grfn' || sub == 'tazjin') && 'Admin') || 'Editor'";
|
|
|
|
|
|
|
|
# Allow creating new Grafana accounts from OAuth accounts.
|
|
|
|
allow_sign_up = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
anonymous = {
|
|
|
|
enabled = true;
|
|
|
|
org_name = "The Virus Lounge";
|
|
|
|
org_role = "Viewer";
|
|
|
|
};
|
|
|
|
|
|
|
|
basic.enabled = false;
|
|
|
|
oauth_auto_login = true;
|
|
|
|
disable_login_form = true;
|
2021-04-13 01:32:40 +02:00
|
|
|
};
|
|
|
|
};
|
2022-01-30 17:06:58 +01:00
|
|
|
inherit (builtins) typeOf replaceStrings listToAttrs concatLists;
|
|
|
|
inherit (lib) toUpper mapAttrsToList nameValuePair concatStringsSep;
|
|
|
|
|
|
|
|
# Take ["auth" "generic_oauth" "enabled"] and turn it into OPTIONS_GENERIC_OAUTH_ENABLED.
|
|
|
|
encodeName = raw: replaceStrings [ "." ] [ "_" ] (toUpper (concatStringsSep "_" raw));
|
|
|
|
|
|
|
|
# Turn an option value into a string, but we want bools to be sensible strings and not "1" or "".
|
|
|
|
optionToString = value:
|
|
|
|
if (typeOf value) == "bool" then
|
|
|
|
if value then "true" else "false"
|
|
|
|
else builtins.toString value;
|
|
|
|
|
|
|
|
# Turn an nested options attrset into a flat listToAttrs-compatible list.
|
|
|
|
encodeOptions = prefix: inp: concatLists (mapAttrsToList
|
|
|
|
(name: value:
|
|
|
|
if (typeOf value) == "set"
|
|
|
|
then encodeOptions (prefix ++ [ name ]) value
|
|
|
|
else [ (nameValuePair (encodeName (prefix ++ [ name ])) (optionToString value)) ]
|
|
|
|
)
|
|
|
|
inp);
|
|
|
|
in
|
|
|
|
listToAttrs (encodeOptions [ ] options);
|
2021-04-12 17:59:51 +02:00
|
|
|
|
|
|
|
provision = {
|
|
|
|
enable = true;
|
|
|
|
datasources = [{
|
|
|
|
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.
|
2021-12-10 13:55:08 +01:00
|
|
|
systemd.services.grafana.serviceConfig.EnvironmentFile = "/run/agenix/grafana";
|
2021-04-12 17:59:51 +02:00
|
|
|
|
2021-12-25 15:06:15 +01:00
|
|
|
services.keycloak = {
|
|
|
|
enable = true;
|
|
|
|
httpPort = "5925"; # "kycl"
|
|
|
|
frontendUrl = "https://auth.tvl.fyi/auth/";
|
|
|
|
|
|
|
|
database = {
|
|
|
|
type = "postgresql";
|
|
|
|
passwordFile = "/run/agenix/keycloak-db";
|
|
|
|
createLocally = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Configure Keycloak to look at forwarded headers from the reverse
|
|
|
|
# proxy.
|
|
|
|
extraConfig = {
|
|
|
|
"subsystem=undertow" = {
|
|
|
|
"server=default-server" = {
|
|
|
|
"http-listener=default" = {
|
|
|
|
proxy-address-forwarding = "true";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# 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 = {
|
|
|
|
users.tazjin = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "git" "wheel" ];
|
2021-04-10 18:05:16 +02:00
|
|
|
shell = pkgs.fish;
|
2020-07-03 16:22:21 +02:00
|
|
|
openssh.authorizedKeys.keys = depot.users.tazjin.keys.all;
|
2020-07-02 20:19:08 +02:00
|
|
|
};
|
|
|
|
|
2020-07-02 21:05:39 +02:00
|
|
|
users.lukegb = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "git" "wheel" ];
|
|
|
|
openssh.authorizedKeys.keys = depot.users.lukegb.keys.all;
|
|
|
|
};
|
|
|
|
|
2020-07-02 21:07:22 +02:00
|
|
|
users.grfn = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "git" "wheel" ];
|
|
|
|
openssh.authorizedKeys.keys = [
|
2021-04-11 23:53:27 +02:00
|
|
|
depot.users.grfn.keys.whitby
|
2020-07-02 21:07:22 +02:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2020-07-15 20:23:59 +02:00
|
|
|
users.isomer = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "git" ];
|
2020-07-23 21:23:37 +02:00
|
|
|
openssh.authorizedKeys.keys = depot.users.isomer.keys.all;
|
2020-07-15 20:23:59 +02:00
|
|
|
};
|
|
|
|
|
2020-07-17 22:51:09 +02:00
|
|
|
users.riking = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "git" ];
|
|
|
|
openssh.authorizedKeys.keys = depot.users.riking.keys.u2f ++ depot.users.riking.keys.passworded;
|
|
|
|
};
|
|
|
|
|
2020-08-05 03:28:52 +02:00
|
|
|
users.edef = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "git" ];
|
|
|
|
openssh.authorizedKeys.keys = depot.users.edef.keys.all;
|
|
|
|
};
|
|
|
|
|
2020-07-23 21:26:37 +02:00
|
|
|
users.qyliss = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "git" ];
|
|
|
|
openssh.authorizedKeys.keys = depot.users.qyliss.keys.all;
|
|
|
|
};
|
|
|
|
|
2020-08-18 00:24:12 +02:00
|
|
|
users.eta = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "git" ];
|
|
|
|
openssh.authorizedKeys.keys = depot.users.eta.keys.whitby;
|
|
|
|
};
|
|
|
|
|
2020-09-28 01:24:45 +02:00
|
|
|
users.cynthia = {
|
|
|
|
isNormalUser = true; # I'm normal OwO :3
|
|
|
|
extraGroups = [ "git" ];
|
|
|
|
openssh.authorizedKeys.keys = depot.users.cynthia.keys.all;
|
|
|
|
};
|
|
|
|
|
2020-09-28 15:22:23 +02:00
|
|
|
users.firefly = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "git" ];
|
|
|
|
openssh.authorizedKeys.keys = depot.users.firefly.keys.whitby;
|
|
|
|
};
|
|
|
|
|
2021-01-13 21:13:24 +01:00
|
|
|
users.sterni = {
|
|
|
|
isNormalUser = true;
|
2021-05-23 21:03:05 +02:00
|
|
|
extraGroups = [ "git" "wheel" ];
|
2021-01-13 21:13:24 +01:00
|
|
|
openssh.authorizedKeys.keys = depot.users.sterni.keys.all;
|
|
|
|
};
|
|
|
|
|
2021-03-26 20:58:55 +01:00
|
|
|
users.flokli = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "git" ];
|
|
|
|
openssh.authorizedKeys.keys = depot.users.flokli.keys.all;
|
|
|
|
};
|
|
|
|
|
2020-07-02 20:19:08 +02:00
|
|
|
# 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
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-07-07 00:18:43 +02:00
|
|
|
security.acme = {
|
|
|
|
acceptTerms = true;
|
2022-01-12 14:43:15 +01:00
|
|
|
defaults.email = "certs@tvl.fyi";
|
2020-07-07 00:18:43 +02:00
|
|
|
};
|
|
|
|
|
2020-07-02 20:19:08 +02:00
|
|
|
system.stateVersion = "20.03";
|
2021-04-12 17:59:51 +02:00
|
|
|
}
|