Sites statique #5
2 changed files with 22 additions and 11 deletions
|
@ -23,14 +23,9 @@ 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 <link xlink:href="https://github.com/adnanh/webhook/blob/master/docs/Hook-Definition.md"/> for supported values";
|
||||
};
|
||||
});
|
||||
description = "An list of enabled webhooks";
|
||||
};
|
||||
internalPort = mkOption {
|
||||
type = types.int;
|
||||
default = 9000;
|
||||
|
@ -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" ];
|
||||
};
|
||||
};
|
||||
|
|
17
hosts/hackens-org/test-webhook.nix
Normal file
17
hosts/hackens-org/test-webhook.nix
Normal file
|
@ -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";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue