summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/deployment/gecloudpad/default.nix
blob: 8b88626a304e1eb2523d81098d5accda56f614be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{ config, lib, pkgs, ... }:
# more than just nginx config but not enough to become a module
let
  wsgi-sock = "${workdir}/uwsgi-gecloudpad.sock";
  workdir = config.services.uwsgi.runDir;
  gecloudpad = pkgs.python3Packages.callPackage ./gecloudpad.nix {};
  gecloudpad_settings = pkgs.writeText "gecloudpad_settings" ''
    BASEURL = "https://etherpad.euer.krebsco.de"
  '';
in {

  services.uwsgi = {
    enable = true;
    user = "nginx";
    plugins = [ "python3" ];
    instance = {
      type = "emperor";
      vassals = {
        gecloudpad = {
          type = "normal";
          pythonPackages = self: with self; [ gecloudpad ];
          socket = wsgi-sock;
          env = ["GECLOUDPAD_SETTINGS=${gecloudpad_settings}"];
        };
      };
    };
  };

  services.nginx = {
    enable = lib.mkDefault true;
    virtualHosts."pad.binaergewitter.de" = {
      enableACME = true;
      forceSSL = true;
      locations = {
        "/".extraConfig = ''
        expires -1;
        uwsgi_pass                  unix://${wsgi-sock};
        uwsgi_param UWSGI_CHDIR     ${gecloudpad}/${pkgs.python.sitePackages};
        uwsgi_param UWSGI_MODULE    gecloudpad.main;
        uwsgi_param UWSGI_CALLABLE  app;
        include                     ${pkgs.nginx}/conf/uwsgi_params;
      '';
      };
    };
  };
}