]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/denise/oms.nix
Add beta for Denise OMS
[perso/Immae/Config/Nix.git] / modules / private / websites / denise / oms.nix
CommitLineData
a295d69f
IB
1{ lib, config, pkgs, ... }:
2let
3 cfg = config.myServices.websites.denise.oms;
cb589b2e 4 varDir = "/var/lib/buildbot/outputs/denise/oms";
485354e5 5 varDirBeta = "/var/lib/buildbot/outputs/denise/oms_beta";
a295d69f 6 socket = "/run/denise_oms/socket.sock";
485354e5 7 socket_beta = "/run/denise_oms_beta/socket.sock";
a295d69f
IB
8in {
9 options.myServices.websites.denise.oms.enable = lib.mkEnableOption "enable Denise's OMS website";
10
11 config = lib.mkIf cfg.enable {
12 services.websites.env.production.vhostConfs.denise_oms = {
13 certName = "denise";
14 addToCerts = true;
15 hosts = [ "oms.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://oms.syanni.eu/
24 ProxyPassReverse / unix://${socket}|http://oms.syanni.eu/
25 ''
26 ];
27 };
28
29 systemd.services.denise-oms = {
30 description = "Denise OMS website";
31 after = [ "network.target" ];
32 wantedBy = [ "multi-user.target" ];
33
34 serviceConfig = {
35 Type = "simple";
36 WorkingDirectory = varDir;
37 ExecStart = let
839b49f1 38 python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask p.matplotlib p.unidecode ]);
a295d69f
IB
39 in
40 "${python}/bin/gunicorn -w4 -p /run/denise_oms/gunicorn.pid --bind unix:${socket} app:app";
41 User = "buildbot";
42 Restart = "always";
43 RestartSec = "5s";
44 PIDFile = "/run/denise_oms/gunicorn.pid";
45 RuntimeDirectory = "denise_oms";
46 StandardOutput = "journal";
47 StandardError = "inherit";
48 };
49 };
485354e5
IB
50
51 services.websites.env.integration.vhostConfs.denise_oms_beta = {
52 certName = "denise";
53 addToCerts = true;
54 hosts = [ "beta.oms.syanni.eu" ];
55 root = null;
56 extraConfig = [
57 ''
58 ProxyPreserveHost on
59 ProxyVia On
60 ProxyRequests Off
61 ProxyPassMatch ^/.well-known/acme-challenge !
62 ProxyPass / unix://${socket_beta}|http://beta.oms.syanni.eu/
63 ProxyPassReverse / unix://${socket_beta}|http://beta.oms.syanni.eu/
64 ''
65 ];
66 };
67
68 systemd.services.denise-oms-beta = {
69 description = "Denise OMS beta website";
70 after = [ "network.target" ];
71 wantedBy = [ "multi-user.target" ];
72
73 serviceConfig = {
74 Type = "simple";
75 WorkingDirectory = varDirBeta;
76 ExecStart = let
77 python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask p.matplotlib p.unidecode ]);
78 in
79 "${python}/bin/gunicorn -w4 -p /run/denise_oms_beta/gunicorn.pid --bind unix:${socket_beta} app:app";
80 User = "buildbot";
81 Restart = "always";
82 RestartSec = "5s";
83 PIDFile = "/run/denise_oms_beta/gunicorn.pid";
84 RuntimeDirectory = "denise_oms_beta";
85 StandardOutput = "journal";
86 StandardError = "inherit";
87 };
88 };
a295d69f
IB
89 };
90}