aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/denise/bingo.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/private/websites/denise/bingo.nix')
-rw-r--r--modules/private/websites/denise/bingo.nix100
1 files changed, 100 insertions, 0 deletions
diff --git a/modules/private/websites/denise/bingo.nix b/modules/private/websites/denise/bingo.nix
new file mode 100644
index 0000000..9130462
--- /dev/null
+++ b/modules/private/websites/denise/bingo.nix
@@ -0,0 +1,100 @@
1{ lib, config, pkgs, ... }:
2let
3 cfg = config.myServices.websites.denise.bingo;
4 varDir = "/var/lib/buildbot/outputs/denise/bingo";
5 varDirBeta = "/var/lib/buildbot/outputs/denise/bingo_beta";
6 socket = "/run/denise_bingo/socket.sock";
7 socket_beta = "/run/denise_bingo_beta/socket.sock";
8in {
9 options.myServices.websites.denise.bingo.enable = lib.mkEnableOption "enable Denise's bingo website";
10
11 config = lib.mkIf cfg.enable {
12 services.websites.env.production.vhostConfs.denise_bingo = {
13 certName = "denise";
14 addToCerts = true;
15 hosts = [ "bingo.syanni.eu" ];
16 root = null;
17 extraConfig = [
18 ''
19 ProxyPreserveHost on
20 ProxyVia On
21 ProxyRequests Off
22 ProxyPassMatch ^/.well-known/acme-challenge !
23 ProxyPass / unix://${socket}|http://bingo.syanni.eu/
24 ProxyPassReverse / unix://${socket}|http://bingo.syanni.eu/
25 ''
26 ];
27 };
28
29 systemd.services.denise-bingo = {
30 description = "Denise bingo website";
31 after = [ "network.target" ];
32 wantedBy = [ "multi-user.target" ];
33
34 serviceConfig = {
35 Type = "simple";
36 WorkingDirectory = varDir;
37 ExecStart = let
38 python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask p.matplotlib p.unidecode ]);
39 in
40 "${python}/bin/gunicorn -w4 -p /run/denise_bingo/gunicorn.pid --bind unix:${socket} app:app";
41 User = "wwwrun";
42 Restart = "always";
43 RestartSec = "5s";
44 PIDFile = "/run/denise_bingo/gunicorn.pid";
45 RuntimeDirectory = "denise_bingo";
46 StandardOutput = "journal";
47 StandardError = "inherit";
48 };
49 };
50
51 security.sudo.extraRules = [
52 {
53 commands = [
54 { options = [ "NOPASSWD" ]; command = "${pkgs.systemd}/bin/systemctl restart denise-bingo-beta.service"; }
55 { options = [ "NOPASSWD" ]; command = "${pkgs.systemd}/bin/systemctl restart denise-bingo.service"; }
56 ];
57 users = ["buildbot"];
58 runAs = "root";
59 }
60 ];
61 services.websites.env.integration.vhostConfs.denise_bingo_beta = {
62 certName = "denise";
63 addToCerts = true;
64 hosts = [ "beta.bingo.syanni.eu" ];
65 root = null;
66 extraConfig = [
67 ''
68 ProxyPreserveHost on
69 ProxyVia On
70 ProxyRequests Off
71 ProxyPassMatch ^/.well-known/acme-challenge !
72 ProxyPass / unix://${socket_beta}|http://beta.bingo.syanni.eu/
73 ProxyPassReverse / unix://${socket_beta}|http://beta.bingo.syanni.eu/
74 ''
75 ];
76 };
77
78 systemd.services.denise-bingo-beta = {
79 description = "Denise bingo beta website";
80 after = [ "network.target" ];
81 wantedBy = [ "multi-user.target" ];
82
83 serviceConfig = {
84 Type = "simple";
85 WorkingDirectory = varDirBeta;
86 ExecStart = let
87 python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask ]);
88 in
89 "${python}/bin/gunicorn -w4 -p /run/denise_bingo_beta/gunicorn.pid --bind unix:${socket_beta} app:app";
90 User = "wwwrun";
91 Restart = "always";
92 RestartSec = "5s";
93 PIDFile = "/run/denise_bingo_beta/gunicorn.pid";
94 RuntimeDirectory = "denise_bingo_beta";
95 StandardOutput = "journal";
96 StandardError = "inherit";
97 };
98 };
99 };
100}