1{
2 config,
3 pkgs,
4 inputs,
5 ...
6}:
7let
8 PUBLIC_BASE_URL = "https://gaze.systems";
9 modules = (pkgs.callPackage "${inputs.blog}/nix/modules.nix" { }).overrideAttrs (_: {
10 # outputHash = "sha256-rzfSfiK8FSNFR+1QTwM/ltLZBprG9BoQsPmOt6IdXFc=";
11 });
12 pkg = pkgs.callPackage "${inputs.blog}/nix" {
13 inherit PUBLIC_BASE_URL;
14 gazesys-modules = modules;
15 };
16 port = 3003;
17 vhostConfig = {
18 locations."/".proxyPass = "http://localhost:${toString port}";
19 locations."/annoy/ws/" = {
20 proxyWebsockets = true;
21 proxyPass = "http://100.64.0.9:3111/";
22 extraConfig = ''
23 rewrite ^/annoy/ws/(.*) /$1 break;
24 '';
25 };
26 locations."/annoy/ws" = {
27 proxyWebsockets = true;
28 proxyPass = "http://100.64.0.9:3111/";
29 extraConfig = ''
30 rewrite ^/annoy/ws(.*) /$1 break;
31 '';
32 };
33 };
34in
35{
36 users.users.website = {
37 isSystemUser = true;
38 group = "website";
39 };
40 users.groups.website = { };
41
42 age.secrets.websiteConfig.file = ../../../secrets/websiteConfig.age;
43
44 systemd.services.website = {
45 description = "website";
46 wantedBy = [ "multi-user.target" ];
47 after = [ "network.target" ];
48 environment = {
49 HOME = "/var/lib/website";
50 ORIGIN = PUBLIC_BASE_URL;
51 PORT = toString port;
52 WEBSITE_DATA_DIR = "/var/lib/website";
53 VITE_CLOUDINARY_CLOUD_NAME = "dgtwf7mar";
54 };
55 serviceConfig = {
56 User = "website";
57 ExecStart = "${pkg}/bin/website";
58 Restart = "on-failure";
59 RestartSec = 5;
60 WorkingDirectory = "/var/lib/website";
61 EnvironmentFile = config.age.secrets.websiteConfig.path;
62 KillSignal = "SIGKILL";
63 };
64 };
65
66 # systemd.services.annoy-keep-alive = {
67 # description = "keeps annoy peer connection alive";
68 # wantedBy = [ "multi-user.target" ];
69 # after = [ "network.target" ];
70 # serviceConfig = {
71 # Type = "oneshot";
72 # ExecStart = "${pkgs.curl}/bin/curl http://100.64.0.1:3111/";
73 # };
74 # };
75 # systemd.timers.annoy-keep-alive.timerConfig = {
76 # OnBootSec = "5 min";
77 # OnUnitActiveSec = "5 min";
78 # Unit = "annoy-keep-alive.service";
79 # };
80
81 services.nginx.virtualHosts."gaze.systems" = vhostConfig;
82 services.nginx.virtualHosts."ptr.pet" = vhostConfig;
83 services.nginx.virtualHosts."poor.dog" = vhostConfig;
84
85 # services.nginx.virtualHosts."poor.dog" = {
86 # locations."=/".return = "301 https://gaze.systems$request_uri";
87 # };
88 # services.nginx.virtualHosts."ptr.pet" = {
89 # locations."=/".return = "301 https://gaze.systems$request_uri";
90 # };
91}