diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-07-03 11:16:38 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-07-03 11:16:38 +0530 |
| commit | b4881b42c8f5f413deef5254e9cd5e39f9472e77 (patch) | |
| tree | 2e930030ddab8b03d4c9f75836ff027a4d137533 /modules/notifications/default.nix | |
| parent | 7761e6de5f85219639dfd1f4fa3b9ea3aabaac5b (diff) | |
| download | nixos-config-b4881b42c8f5f413deef5254e9cd5e39f9472e77.tar.gz nixos-config-b4881b42c8f5f413deef5254e9cd5e39f9472e77.zip | |
Bacchus ntfy subscribe
Diffstat (limited to '')
| -rw-r--r-- | modules/notifications/default.nix | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/modules/notifications/default.nix b/modules/notifications/default.nix new file mode 100644 index 0000000..8447a1e --- /dev/null +++ b/modules/notifications/default.nix @@ -0,0 +1,50 @@ +{ pkgs, lib, ... }: +let + ntfyCfg = { + default-host = "http://192.168.0.117:3142"; + subscribe = [ + { + topic = "media_update"; + command = ''${notify} "$title" "$message"''; + } + { + topic = "ping"; + command = ''${notify} "PING: $title" "$message"''; + } + { + topic = "jellyseer"; + command = ''${notify} "$(echo "$m" | ${jq} -r .title)" "$(echo "$m" | ${jq} -r .body)"''; + } + { + topic = "grafana_alert"; + command = ''${notify} "Grafana alert" "$message"''; + } + ]; + }; + sudo = "${pkgs.sudo}/bin/sudo"; + jq = "${pkgs.jq}/bin/jq"; + notify = "${sudo} -u imsohexy ${pkgs.libnotify}/bin/notify-send -a ntfy"; +in +{ + environment.systemPackages = with pkgs; [ ntfy-sh ]; + + systemd.services.ntfy-client = { + unitConfig = { + Description = "ntfy client"; + After = "network.service"; + }; + + serviceConfig = let + ntfyCfgFile = pkgs.writeText "client.yml" (lib.generators.toYAML {} ntfyCfg); + in { + ExecStart = "${pkgs.ntfy-sh}/bin/ntfy subscribe --config ${ntfyCfgFile} --from-config"; + Restart = "on-failure"; + Environment = lib.concatStringsSep " " [ + "PATH=${pkgs.dbus}/bin:${pkgs.libnotify}/bin:/bin:/usr/bin" + "DISPLAY=:0" + ]; + }; + + wantedBy = ["multi-user.target"]; + }; +} |
