-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrate-with-science.nix
More file actions
48 lines (44 loc) · 1.29 KB
/
Copy pathrate-with-science.nix
File metadata and controls
48 lines (44 loc) · 1.29 KB
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
{ config, lib, pkgs, ... }:
let
rws = pkgs.callPackage ./pkgs/rws.nix {};
in
{
users.extraUsers.ratews = {
description = "Rate With Science server user";
uid = 200000;
home = "${rws}";
isSystemUser = true;
};
systemd.services.ratews = {
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
WorkingDirectory= "${rws}";
ExecStart = "${rws}/bin/ratewithscience";
User = "ratews";
Restart = "on-failure";
};
};
# Since the site is used infrequently but when it is, it needs to quickly traverse
# 500MB of memory in random order, getting swapped out is deadly and basically
# makes it unusable. Make the system try very hard not to swap things out for this reason.
boot.kernel.sysctl = { "vm.swappiness" = 0; };
services.nginx.httpConfig = ''
server {
server_name ratewith.science ratewithscience.thume.ca ratewithscience.thume.net;
root ${rws}/public;
listen 80;
keepalive_timeout 20;
index index.html;
location / {
try_files $uri $uri/index.html @app;
}
location @app {
proxy_set_header Host $host;
proxy_redirect off;
proxy_pass http://localhost:5000;
}
}
'';
networking.firewall.allowedTCPPorts = [80 5000];
}