-
Notifications
You must be signed in to change notification settings - Fork 3
/
module.nix
63 lines (54 loc) · 1.39 KB
/
module.nix
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
51
52
53
54
55
56
57
58
59
60
61
62
63
{ pkgs, config, lib, ... }:
let
cfg = config.dd-ix.website;
package = cfg.package.override {
inherit (cfg) contentApi;
};
in
{
options.dd-ix.website = {
enable = lib.mkEnableOption "website";
package = lib.mkPackageOption pkgs "website" { };
domain = lib.mkOption {
type = lib.types.str;
description = "The domain the frontend should be served.";
};
contentApi = lib.mkOption {
type = lib.types.str;
description = "The domain the content api is listening.";
};
};
config = lib.mkIf cfg.enable {
systemd.services.website = {
enable = true;
wantedBy = [ "multi-user.target" ];
environment = {
APP_DIR = package;
};
serviceConfig = {
ExecStart = "${pkgs.nodejs}/bin/node ${package}/server.mjs";
DynamicUser = true;
Restart = "always";
};
};
services.nginx = {
enable = true;
virtualHosts."${cfg.domain}".locations = {
"/" = {
root = "${package}/browser";
# just something that does not exists
index = "X6XewZMsmreGIxx1lCdp0Yo1X4qHTivW";
tryFiles = "$uri @website";
extraConfig = ''
expires max;
access_log off;
'';
};
"@website" = {
recommendedProxySettings = true;
proxyPass = "http://127.0.0.1:4000";
};
};
};
};
}