{...}: { config.flake.modules.homeManager.homey-alert = { lib, config, pkgs, ... }: { options.azos.homey-alert.enable = lib.mkOption { default = false; example = true; type = lib.types.bool; }; config = lib.mkIf config.azos.homey-alert.enable { azos.claude.globalSkills.notify = ./notify-skill.md; home.packages = [ (pkgs.writeShellApplication { name = "homey-alert"; runtimeInputs = with pkgs; [curl pass]; text = '' usage() { cat <&2; usage >&2; exit 1 ;; *) break ;; esac done if [[ $# -gt 0 ]]; then MESSAGE="$*" elif [[ ! -t 0 ]]; then MESSAGE="$(cat)" else echo "homey-alert: no message provided" >&2 usage >&2 exit 1 fi TOKEN="$(pass zakobar-homecenter/ntfy-token)" # Build the curl invocation as an array — single source of truth for both modes CMD=( curl -sf -H "Authorization: Bearer $TOKEN" -H "Priority: $PRIORITY" ) [[ -n "$TITLE" ]] && CMD+=(-H "Title: $TITLE") [[ -n "$TAGS" ]] && CMD+=(-H "Tags: $TAGS") CMD+=(-d "$MESSAGE" https://ntfy.zakobar.com/alerts) if $PRINT_REMOTE; then # Shell-quote each element so the output is safe to embed in SSH commands printf '%q ' "''${CMD[@]}" printf '\n' else "''${CMD[@]}" fi ''; }) ]; }; }; }