2023-12-23 23:29:27 +00:00
|
|
|
{ system, pkgs, lib, ... }:
|
2023-12-23 21:29:18 +00:00
|
|
|
let
|
|
|
|
boardwise = builtins.getFlake
|
2024-01-10 19:29:34 +00:00
|
|
|
"github:boardwise-gg/website/ef264d6670199157761602093f9bf52bb471c4b8";
|
2023-12-23 21:29:18 +00:00
|
|
|
coach-scraper = builtins.getFlake
|
|
|
|
"github:boardwise-gg/coach-scraper/58815d3ae5a69cac12436a01e77019a5ac5d16a7";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
services = {
|
|
|
|
nginx.virtualHosts."www.boardwise.gg" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
serverAliases = [ "boardwise.gg" ];
|
|
|
|
locations."/" = {
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
proxyPass = "http://127.0.0.1:4000";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
postgresql = {
|
|
|
|
package = pkgs.postgresql_15;
|
|
|
|
ensureDatabases = [ "boardwise" ];
|
|
|
|
authentication = lib.mkOverride 10 ''
|
|
|
|
# TYPE DATABASE USER ADDRESS METHOD
|
|
|
|
local all all trust
|
|
|
|
host all all 127.0.0.1/32 trust
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.boardwise = {
|
|
|
|
enable = true;
|
|
|
|
description = "BoardWise Server";
|
|
|
|
after = [ "postgresql.service" ];
|
|
|
|
requires = [ "postgresql.service" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Environment = [
|
|
|
|
"DATABASE_URL=ecto://postgres:postgres@localhost/boardwise"
|
|
|
|
];
|
2024-01-10 17:44:20 +00:00
|
|
|
EnvironmentFile = "/run/secrets/BOARDWISE_SECRET_KEY_BASE";
|
2023-12-23 21:29:18 +00:00
|
|
|
ExecStartPre = "${boardwise.packages.${system}.app}/bin/migrate";
|
|
|
|
ExecStart = "${boardwise.packages.${system}.app}/bin/boardwise start";
|
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = [
|
|
|
|
coach-scraper.packages.${system}.app
|
|
|
|
];
|
|
|
|
|
|
|
|
sops = {
|
|
|
|
defaultSopsFile = ./secrets.yaml;
|
2024-01-10 17:44:20 +00:00
|
|
|
secrets.BOARDWISE_SECRET_KEY_BASE = {};
|
2023-12-23 21:29:18 +00:00
|
|
|
};
|
|
|
|
}
|