From d16ac26712cbb2d6da1e4b72147d92f0e0c8086b Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Tue, 31 Jan 2023 13:53:32 +0100 Subject: [PATCH] add ring webhook --- flake.lock | 8 +++--- nixos/machines/pepe/configuration.nix | 2 ++ nixos/machines/robi/configuration.nix | 1 + nixos/machines/robi/webhook-ring.nix | 37 +++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 nixos/machines/robi/webhook-ring.nix diff --git a/flake.lock b/flake.lock index 552c532..7b39c25 100644 --- a/flake.lock +++ b/flake.lock @@ -936,11 +936,11 @@ "secrets": { "flake": false, "locked": { - "lastModified": 1674110639, - "narHash": "sha256-IpvJcMtRxcUM4gk8Ha0yKsIJs7Dmo+r9XBb8wUM2sDo=", + "lastModified": 1675168228, + "narHash": "sha256-n2SBJNQxdWZhnqQwTZS2QDCiPDyBPHHUslGTEpAYCTk=", "ref": "main", - "rev": "ef5f10f16f670e26c950bacf95d3d0ec90f0a371", - "revCount": 40, + "rev": "ca6040e71ff71e905d896bdbdf8f9c74930ecc78", + "revCount": 41, "type": "git", "url": "ssh://gitea@git.ingolf-wagner.de/palo/nixos-secrets.git" }, diff --git a/nixos/machines/pepe/configuration.nix b/nixos/machines/pepe/configuration.nix index d4e7b71..5d8341c 100644 --- a/nixos/machines/pepe/configuration.nix +++ b/nixos/machines/pepe/configuration.nix @@ -67,5 +67,7 @@ # todo move to some place else home-manager.users.mailUser.home.stateVersion = "22.11"; + + } diff --git a/nixos/machines/robi/configuration.nix b/nixos/machines/robi/configuration.nix index 82c0800..0e66bdb 100644 --- a/nixos/machines/robi/configuration.nix +++ b/nixos/machines/robi/configuration.nix @@ -30,6 +30,7 @@ ./wireguard.nix ./jellyfin.nix + #./webhook-ring.nix #../../system/server diff --git a/nixos/machines/robi/webhook-ring.nix b/nixos/machines/robi/webhook-ring.nix new file mode 100644 index 0000000..40ded34 --- /dev/null +++ b/nixos/machines/robi/webhook-ring.nix @@ -0,0 +1,37 @@ +{ config, pkgs, ... }: +{ + + sops.secrets.ringPushover = { + owner = config.services.webhook.user; + }; + + services.webhook = { + enable = true; + hooks = { + ring = { + execute-command = + let + script = pkgs.writers.writeBash "ring-script" '' + . ${config.sops.secrets.ringPushover.path} + ${pkgs.curl}/bin/curl -s \ + --form-string "token=$API_KEY" \ + --form-string "user=$USER_KEY" \ + --form-string "title=Klingeling" \ + --form-string "message=Jemand an der Tür" \ + https://api.pushover.net/1/messages.json + ''; + in + toString script; + response-message = "It's ringing"; + }; + }; + }; + + services.nginx.virtualHosts."ring.ingolf-wagner.de" = { + enableACME = true; + forceSSL = true; + locations."/" = { + proxyPass = "http://localhost:${toString config.services.webhook.port}/${config.services.webhook.urlPrefix}/ring"; + }; + }; +}