diff --git a/hosts/hackens-org/modules/webhook.nix b/hosts/hackens-org/modules/webhook.nix index 62d3562..130885e 100644 --- a/hosts/hackens-org/modules/webhook.nix +++ b/hosts/hackens-org/modules/webhook.nix @@ -23,13 +23,8 @@ in description = "The endpoint of the webhooks"; }; hooks = mkOption { - type = types.listOf (types.submodule { - options = mkOption { - type = json.type; - description = "Configuration for this webhook, check for supported values"; - }; - }); - description = "An list of enabled webhooks"; + type = json.type; + description = "Configuration for this webhook, check for supported values"; }; internalPort = mkOption { type = types.int; @@ -41,18 +36,17 @@ in services.nginx = { enable = true; virtualHosts."${cfg.hostname}" = { - locations."${endpoint}".proxyPass = "http://127.0.0.1:${cfg.internalPort}/hooks"; + locations."${cfg.endPoint}".proxyPass = "http://127.0.0.1:${toString cfg.internalPort}/hooks"; enableACME = if debug then false else true; }; }; systemd.services.webhook = { + enable = true; unitConfig = { Description = "Small server for creating HTTP hooks"; Documentation = "https://github.com/adnanh/webhook/"; }; - serviceConfig = { - ExecStart = "${cfg.pkg} -ip \"127.0.0.1\" -port \"${cfg.internalPort}\" -verbose -hooks ${json.generate "conf.json" cfg.hooks}"; - }; + script = "${cfg.pkg}/bin/webhook -nopanic -ip \"127.0.0.1\" -port \"${toString cfg.internalPort}\" -verbose -hooks ${json.generate "conf.json" cfg.hooks}"; wantedBy = [ "mulit-user.target" ]; }; }; diff --git a/hosts/hackens-org/test-webhook.nix b/hosts/hackens-org/test-webhook.nix new file mode 100644 index 0000000..b287451 --- /dev/null +++ b/hosts/hackens-org/test-webhook.nix @@ -0,0 +1,17 @@ +{ config, pkgs, ... }: +{ + services.webhook = { + enable = true; + hostname = "test-webhook.${config.my.subZone}"; + hooks = [ + { + id = "testhook"; + execute-command = pkgs.writeScript "echo.sh" '' + #!/bin/sh + echo "Bonjour" + ''; + response-message = "Test hook sucess"; + } + ]; + }; +}