summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/deployment/mycube.connector.one.nix
blob: 091b7f21bf62378c03409df68877612c4296ebe0 (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
47
48
49
50
{ config, lib, pkgs, ... }:
# more than just nginx config but not enough to become a module
with import <stockholm/lib>;
let
  hostname = config.krebs.build.host.name;
  external-ip = config.krebs.build.host.nets.internet.ip4.addr;
  wsgi-sock = "${config.services.uwsgi.runDir}/uwsgi.sock";
in {
  services.redis = {
    enable = true;
  };
  systemd.services.redis.serviceConfig.LimitNOFILE=10032;

  services.uwsgi = {
    enable = true;
    user = "nginx";
    plugins = [ "python2" ];
    instance = {
      type = "emperor";
      vassals = {
        mycube-flask = {
          type = "normal";
          pythonPackages = self: with self; [ pkgs.mycube-flask ];
          socket = wsgi-sock;
        };
      };
    };
  };

  krebs.nginx = {
    enable = mkDefault true;
    servers = {
      mybox-connector-one = {
        listen = [ "${external-ip}:80" ];
        server-names = [
          "mycube.connector.one"
          "mybox.connector.one"
        ];
        locations = singleton (nameValuePair "/" ''
          uwsgi_pass unix://${wsgi-sock};
          uwsgi_param         UWSGI_CHDIR     ${pkgs.mycube-flask}/${pkgs.python.sitePackages};
          uwsgi_param         UWSGI_MODULE    mycube.websrv;
          uwsgi_param         UWSGI_CALLABLE  app;

          include ${pkgs.nginx}/conf/uwsgi_params;
        '');
      };
    };
  };
}