nixos-configuration/hive/phobos/default.nix

86 lines
2.2 KiB
Nix
Raw Normal View History

2023-12-12 15:18:35 +00:00
{ system, stateVersion, sops-nix, pkgs, lib, ... }:
let
boardwise = builtins.getFlake
2023-12-12 19:24:48 +00:00
"github:boardwise-gg/website/db73e3b4f06659fd477be8e76594c01a185f1496";
coach-scraper = builtins.getFlake
"github:boardwise-gg/coach-scraper/58815d3ae5a69cac12436a01e77019a5ac5d16a7";
in
{
imports = lib.optional (builtins.pathExists ./do-userdata.nix) ./do-userdata.nix ++ [
2023-12-12 15:18:35 +00:00
../../digital-ocean/configuration.nix
sops-nix.nixosModules.sops
];
deployment.targetHost = "143.198.142.171";
networking = {
hostName = "phobos";
firewall = {
enable = true;
allowedTCPPorts = [ 80 443 ];
};
};
2023-12-12 14:35:29 +00:00
programs.mosh.enable = true;
2023-12-12 16:27:39 +00:00
services.openssh.enable = true;
services.postgresql = {
enable = true;
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"
];
EnvironmentFile = "/run/secrets/SECRET_KEY_BASE";
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
];
2023-12-12 16:07:30 +00:00
sops = {
defaultSopsFile = ./secrets.yaml;
secrets.SECRET_KEY_BASE = {};
};
security.acme = {
acceptTerms = true;
defaults.email = "jrpotter2112@gmail.com";
};
2023-12-12 14:35:29 +00:00
services.nginx = {
enable = true;
virtualHosts = {
"www.boardwise.gg" = {
2023-12-12 15:18:35 +00:00
forceSSL = true;
2023-12-12 14:35:29 +00:00
enableACME = true;
serverAliases = [ "boardwise.gg" ];
locations."/" = {
recommendedProxySettings = true;
proxyPass = "http://127.0.0.1:4000";
};
};
};
};
system.stateVersion = stateVersion;
}