2019-02-22 13:10:02 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.beanstalkd;
|
|
|
|
pkg = pkgs.beanstalkd;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
# interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.beanstalkd = {
|
2022-08-28 20:18:44 +01:00
|
|
|
enable = mkEnableOption (lib.mdDoc "the Beanstalk work queue");
|
2019-02-22 13:10:02 +00:00
|
|
|
|
|
|
|
listen = {
|
|
|
|
port = mkOption {
|
|
|
|
type = types.int;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "TCP port that will be used to accept client connections.";
|
2019-02-22 13:10:02 +00:00
|
|
|
default = 11300;
|
|
|
|
};
|
|
|
|
|
|
|
|
address = mkOption {
|
|
|
|
type = types.str;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "IP address to listen on.";
|
2019-02-22 13:10:02 +00:00
|
|
|
default = "127.0.0.1";
|
|
|
|
example = "0.0.0.0";
|
|
|
|
};
|
|
|
|
};
|
2020-09-01 15:07:28 +01:00
|
|
|
|
|
|
|
openFirewall = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Whether to open ports in the firewall for the server.";
|
2020-09-01 15:07:28 +01:00
|
|
|
};
|
2019-02-22 13:10:02 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2020-09-01 15:07:28 +01:00
|
|
|
networking.firewall = mkIf cfg.openFirewall {
|
|
|
|
allowedTCPPorts = [ cfg.listen.port ];
|
|
|
|
};
|
|
|
|
|
2019-02-22 13:10:02 +00:00
|
|
|
environment.systemPackages = [ pkg ];
|
|
|
|
|
|
|
|
systemd.services.beanstalkd = {
|
|
|
|
description = "Beanstalk Work Queue";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = true;
|
|
|
|
Restart = "always";
|
2019-11-22 09:27:32 +00:00
|
|
|
ExecStart = "${pkg}/bin/beanstalkd -l ${cfg.listen.address} -p ${toString cfg.listen.port} -b $STATE_DIRECTORY";
|
|
|
|
StateDirectory = "beanstalkd";
|
2019-02-22 13:10:02 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|