]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add ntfy notification pusher
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 22 Aug 2022 08:05:27 +0000 (10:05 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 9 Apr 2023 15:16:26 +0000 (17:16 +0200)
flakes/backports/flake.lock [new file with mode: 0644]
flakes/backports/flake.nix [new file with mode: 0644]
modules/private/websites/tools/tools/default.nix
overlays/default.nix

diff --git a/flakes/backports/flake.lock b/flakes/backports/flake.lock
new file mode 100644 (file)
index 0000000..2d046a2
--- /dev/null
@@ -0,0 +1,43 @@
+{
+  "nodes": {
+    "flake-utils": {
+      "locked": {
+        "lastModified": 1656928814,
+        "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1659522808,
+        "narHash": "sha256-HBcM19nGhI3IWwPNVlYb0MZ8VW6iKp4JbAVkeIHVykc=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "168d1c578909dc143ba52dbed661c36e76b12b36",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-utils": "flake-utils",
+        "nixpkgs": "nixpkgs"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/flakes/backports/flake.nix b/flakes/backports/flake.nix
new file mode 100644 (file)
index 0000000..796664a
--- /dev/null
@@ -0,0 +1,37 @@
+{
+  description = "Backported packages";
+
+  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+  inputs.flake-utils.url = "github:numtide/flake-utils";
+
+  outputs = { self, flake-utils, nixpkgs }: flake-utils.lib.eachDefaultSystem (system:
+    let
+      pkgs = import nixpkgs { inherit system; overlays = []; config = {}; };
+    in rec {
+      packages = {
+        ntfy-sh = pkgs.ntfy-sh;
+      };
+      legacyPackages = packages;
+      apps = {
+        ntfy-sh = flake-utils.lib.mkApp { drv = packages.ntfy-sh; name = "ntfy-sh"; };
+      };
+    }
+  ) // rec {
+    lib = {
+      overrideDeps = pkgs: package: let
+          packageDeps = builtins.attrNames package.override.__functionArgs;
+        in package.override (pkgs.lib.genAttrs packageDeps (n: pkgs."${n}"));
+    };
+    overlays = {
+      ntfy-sh = final: prev: { ntfy-sh = self.packages."${final.system}".ntfy-sh; };
+    };
+    overlay = final: prev: ({}
+      // overlays.ntfy-sh final prev
+    );
+
+    nixosModules = {
+      #coturn = import (nixpkgs + "/nixos/modules/services/networking/coturn.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" ];
index 3f01f45b7cb6202fc30168824b6d7bcdb99006a1..c0242f3af434ba7e65dc3faa7634b7142861627e 100644 (file)
@@ -1,6 +1,7 @@
 let
   flakeCompat = import ../lib/flake-compat.nix;
   flakes = builtins.foldl' (a: b: a // b) {} (map (n: (flakeCompat n).overlays) [
+    ../flakes/backports
     ../flakes/etherpad-lite
     ../flakes/grocy
     ../flakes/openarc