Webhook service
This commit is contained in:
parent
d605ff2378
commit
b72022b012
2 changed files with 56 additions and 0 deletions
|
@ -5,5 +5,6 @@
|
||||||
./acme-ssl.nix
|
./acme-ssl.nix
|
||||||
./staticWebsite.nix
|
./staticWebsite.nix
|
||||||
./nginx.nix
|
./nginx.nix
|
||||||
|
./webhook.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
55
hosts/hackens-org/modules/webhook.nix
Normal file
55
hosts/hackens-org/modules/webhook.nix
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
{ pkgs, config, lib, ... }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
json = pkgs.formats.json {};
|
||||||
|
cfg = config.services.webhook;
|
||||||
|
debug = config.my.debug;
|
||||||
|
in
|
||||||
|
options.services.webhook = {
|
||||||
|
enable = mkEnableOption "Set up webhooks";
|
||||||
|
pkg = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
default = pkgs.webhook;
|
||||||
|
description = "`webhook` package to use";
|
||||||
|
};
|
||||||
|
hostname = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "The vhost on which webhook will listen";
|
||||||
|
};
|
||||||
|
endPoint = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "hooks";
|
||||||
|
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;
|
||||||
|
description = "The local port used to (proxy)pass requests from nginx to webhook";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
services.nginx = {
|
||||||
|
enableACME = if debug then false else true;
|
||||||
|
enable = true;
|
||||||
|
virtualHosts."${cfg.hostname}".locations."${endpoint}".proxyPass = "http://127.0.0.1:${cfg.internalPort}/hooks";
|
||||||
|
};
|
||||||
|
systemd.services.webhook = {
|
||||||
|
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}";
|
||||||
|
};
|
||||||
|
wantedBy = [ "mulit-user.target" ];
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue