]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/tools/tools/default.nix
Add ntfy notification pusher
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / tools / default.nix
index 133ab9f766e1fa89b31181670e6990ce3e2a1dc4..99c746d7d6a4455a38e0534fee2857d294039bd5 100644 (file)
@@ -210,6 +210,20 @@ in {
             ProxyPreserveHost on
           </Location>
 
+          <Location "/ntfy/">
+            SetEnv proxy-nokeepalive 1
+            SetEnv proxy-sendchunked 1
+            LimitRequestBody 102400
+
+            RewriteEngine On
+
+            # FIXME: why is landing prefixed in the url?
+            RewriteCond %{HTTP:Upgrade} websocket [NC]
+            RewriteCond %{HTTP:Connection} upgrade [NC]
+            RewriteRule ^(${landing}/ntfy)?/?(.*) unix:///run/ntfy/ntfy.sock|ws://tools.immae.eu/$2 [P,NE,QSA,L]
+
+            RewriteRule ^(${landing}/ntfy)?/?(.*) unix:///run/ntfy/ntfy.sock|http://tools.immae.eu/$2 [P,NE,QSA,L]
+          </Location>
           Alias /BIP39 /var/lib/buildbot/outputs/immae/bip39
           <Directory "/var/lib/buildbot/outputs/immae/bip39">
             DirectoryIndex index.html
@@ -297,6 +311,18 @@ in {
         after = lib.mkAfter yourls.phpFpm.serviceDeps;
         wants = yourls.phpFpm.serviceDeps;
       };
+      ntfy = {
+        description = "send push notifications to your phone or desktop via scripts from any computer";
+        wantedBy = [ "multi-user.target" ];
+        serviceConfig = {
+          ExecStart = "${pkgs.ntfy-sh}/bin/ntfy serve --listen-http '' --listen-unix %t/ntfy/ntfy.sock --cache-file %S/ntfy/cache.db --cache-duration 120h --behind-proxy --attachment-cache-dir %S/ntfy/attachments --base-url https://tools.immae.eu/ntfy";
+          Type = "simple";
+          WorkingDirectory = "%S/ntfy";
+          RuntimeDirectory = "ntfy";
+          StateDirectory = "ntfy";
+          User = "wwwrun";
+        };
+      };
       ympd = {
         description = "Standalone MPD Web GUI written in C";
         wantedBy = [ "multi-user.target" ];