diff --git a/hosts/jpporta-nixos/home.nix b/hosts/jpporta-nixos/home.nix index 1d6525e..da51baa 100644 --- a/hosts/jpporta-nixos/home.nix +++ b/hosts/jpporta-nixos/home.nix @@ -97,7 +97,23 @@ }; openspec.enable = true; power-profiles.enable = true; - ntfy-notify.enable = true; + ntfy-notify = { + enable = true; + server = "https://ntfy.joaoporta.com"; + subscriptions = [ + { + priority = "normal"; + topic = "music-download"; + title = "Music Downloaded"; + } + { + priority = "critical"; + topic = "joao-kanban"; + title = "Kanban Update"; + } + ]; + + }; bitwarden.enable = true; }; home.packages = diff --git a/modules/home-manager/ntfy-notify/default.nix b/modules/home-manager/ntfy-notify/default.nix index 3f130e5..f002240 100644 --- a/modules/home-manager/ntfy-notify/default.nix +++ b/modules/home-manager/ntfy-notify/default.nix @@ -6,6 +6,16 @@ }: let cfg = config.custom.ntfy-notify; + ntfy-notify = pkgs.writeShellApplication { + name = "ntfy-notify-authenticated"; + runtimeInputs = with pkgs; [ ntfy-sh rbw ]; + text = '' + username="$(rbw get --field username ntfy.joaoporta.com)" + password="$(rbw get ntfy.joaoporta.com)" + export NTFY_USER="$username:$password" + exec ntfy subscribe --from-config + ''; + }; in { options.custom.ntfy-notify = { @@ -24,6 +34,10 @@ in type = lib.types.str; description = "ntfy topic to subscribe to."; }; + title = lib.mkOption { + type = lib.types.str; + description = "Notification title for this topic"; + }; priority = lib.mkOption { type = lib.types.enum [ "low" "normal" "critical" ]; default = "normal"; @@ -35,6 +49,7 @@ in { topic = "joao-kanban"; priority = "critical"; + title = "Kanban Update"; } ]; description = '' @@ -56,7 +71,7 @@ in subscribe: '' + lib.concatMapStringsSep "\n" (sub: let - cmd = "${lib.getExe pkgs.libnotify} -a Kanban -u ${sub.priority} \"Kanban Update\" \"$m\""; + cmd = "${lib.getExe pkgs.libnotify} -a ntfy -u ${sub.priority} \"${sub.title}\" \"$m\""; in " - topic: ${cfg.server}/${sub.topic}\n" + " command: ${cmd}" @@ -71,7 +86,7 @@ in }; Service = { Type = "simple"; - ExecStart = "${pkgs.ntfy-sh}/bin/ntfy subscribe --from-config"; + ExecStart = "${ntfy-notify}/bin/ntfy-notify-authenticated"; Restart = "on-failure"; RestartSec = 10; };