traque test

This commit is contained in:
catvayor 2024-06-23 15:57:17 +02:00
parent eb4634e71c
commit 5ce5243fb8
5 changed files with 148 additions and 4 deletions

View file

@ -98,7 +98,11 @@ in
domains = [ host ]; domains = [ host ];
loginAccounts = { loginAccounts = {
"user1@${host}" = { "root@${host}" = {
catchAll = [
host
];
aliases = builtins.genList (id: "user${toString id}@${host}") 10 ++ [ "moderators@${host}" ];
hashedPassword = "$2b$05$FoCVDECXYG0KXPigPuIZtuNFiviwSg8RuXx0FbnzC7ZRp.Mz8VWOe"; hashedPassword = "$2b$05$FoCVDECXYG0KXPigPuIZtuNFiviwSg8RuXx0FbnzC7ZRp.Mz8VWOe";
}; };
}; };

View file

@ -126,6 +126,10 @@
vm = "192.168.122.4"; vm = "192.168.122.4";
sshport = 22001; sshport = 22001;
}; };
"test.traque.katvayor.net" = {
vm = "192.168.122.4";
sshport = null;
};
}; };
in in
{ {
@ -141,6 +145,13 @@
locations."/" = { locations."/" = {
recommendedProxySettings = true; recommendedProxySettings = true;
proxyPass = "https://${vm}/"; proxyPass = "https://${vm}/";
extraConfig = ''
proxy_set_header Connection ''';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
'';
}; };
} }
) vhosts; ) vhosts;
@ -149,7 +160,7 @@
lib.mapAttrsToList ( lib.mapAttrsToList (
vhost: vhost:
{ vm, sshport }: { vm, sshport }:
'' lib.optionalString (!isNull sshport) ''
server { server {
listen ${toString sshport}; listen ${toString sshport};
proxy_pass ${vm}:22; proxy_pass ${vm}:22;

View file

@ -6,7 +6,9 @@
pkgs, pkgs,
... ...
}: }:
let
traque-pkg = pkgs.callPackage ./traque-pkg.nix {};
in
{ {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
@ -80,5 +82,105 @@
networking.firewall.enable = false; networking.firewall.enable = false;
security.acme = {
acceptTerms = true;
defaults.email = "root@katvayor.net";
};
services.nginx = {
enable = true;
virtualHosts = {
"traque.katvayor.net" = {
enableACME = true;
addSSL = true;
locations = {
"/" = {
root = "${traque-pkg}/share/traque-webroot";
tryFiles = "$uri $uri.html @backend";
};
"@backend" = {
recommendedProxySettings = true;
proxyPass = "http://localhost:8080";
extraConfig = ''
error_page 502 =503 "/errors/503.html";
proxy_set_header Connection ''';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
'';
};
};
};
"test.traque.katvayor.net" = {
enableACME = true;
addSSL = true;
locations = {
"/" = {
root = "/traque/static";
tryFiles = "$uri $uri.html @backend";
};
"@backend" = {
recommendedProxySettings = true;
proxyPass = "http://localhost:8000";
extraConfig = ''
error_page 502 =503 "/errors/503.html";
proxy_set_header Connection ''';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
'';
};
};
};
};
};
systemd.services = {
traque = {
preStart = ''
cat <<EOF > /var/lib/traque/Rocket.toml
[release]
port = 8080
ident = "Traque backend"
template_dir = "${traque-pkg}/share/traque-templates"
blurred_move = [0.0005, 0.0005]
bonus_timeout = 5000
event_timeout = 100
admin_token = "root"
serve_static = false
teams = [
{ id = "team00", name = "Équipe 00", vieux = false},
{ id = "team01", name = "Équipe 01", vieux = false},
{ id = "npc0", name = "PNJ 0", vieux = true},
{ id = "npc1", name = "PNJ 1", vieux = true},
]
EOF
'';
serviceConfig = {
WorkingDirectory = "/var/lib/traque";
ExecStart = "${traque-pkg}/bin/traque";
ExecReload = [
"${pkgs.coreutils}/bin/kill -HUP $MAINPID"
];
User = "traque";
Group = "traque";
DynamicUser = true;
Restart = "on-failure";
RestartSec = 2;
LogsDirectory = "traque";
StateDirectory = "traque";
RuntimeDirectory = "traque";
};
};
};
users = {
users.traque = {
group = "traque";
isSystemUser = true;
};
groups.traque = { };
};
system.stateVersion = "23.11"; # Did you read the comment? system.stateVersion = "23.11"; # Did you read the comment?
} }

View file

@ -0,0 +1,19 @@
{ lib
, rustPlatform
}:
rustPlatform.buildRustPackage rec {
pname = "traque";
version = "0.2.4";
src = fetchTarball "https://git.dgnum.eu/lbailly/traque/archive/master.tar.gz";
cargoLock = {
lockFile = "${src}/Cargo.lock";
};
postInstall = ''
mkdir -p $out/share
cp -r static $out/share/traque-webroot
cp -r templates $out/share/traque-templates
'';
}

View file

@ -65,6 +65,7 @@
"degette.katvayor.net" = 22000; "degette.katvayor.net" = 22000;
"traque.katvayor.net" = 22001; "traque.katvayor.net" = 22001;
"betamail.katvayor.net" = 22002; "betamail.katvayor.net" = 22002;
"test.traque.katvayor.net" = null;
}; };
in in
{ {
@ -77,11 +78,18 @@
locations."/" = { locations."/" = {
recommendedProxySettings = true; recommendedProxySettings = true;
proxyPass = "https://${kat-r86s}/"; proxyPass = "https://${kat-r86s}/";
extraConfig = ''
proxy_set_header Connection ''';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
'';
}; };
}) vhosts; }) vhosts;
streamConfig = streamConfig =
builtins.concatStringsSep "\n" ( builtins.concatStringsSep "\n" (
lib.mapAttrsToList (vhost: sshport: '' lib.mapAttrsToList (vhost: sshport: lib.optionalString (!isNull sshport) ''
server { server {
listen ${toString sshport}; listen ${toString sshport};
proxy_pass ${kat-r86s}:${toString sshport}; proxy_pass ${kat-r86s}:${toString sshport};