2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.epmd;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options.services.epmd = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to enable socket activation for Erlang Port Mapper Daemon (epmd),
|
|
|
|
which acts as a name server on all hosts involved in distributed
|
|
|
|
Erlang computations.
|
|
|
|
'';
|
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "erlang" { };
|
2021-09-18 10:52:07 +00:00
|
|
|
listenStream = mkOption
|
|
|
|
{
|
|
|
|
type = types.str;
|
|
|
|
default = "[::]:4369";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-09-18 10:52:07 +00:00
|
|
|
the listenStream used by the systemd socket.
|
2022-12-28 21:21:41 +00:00
|
|
|
see https://www.freedesktop.org/software/systemd/man/systemd.socket.html#ListenStream= for more information.
|
2021-09-18 10:52:07 +00:00
|
|
|
use this to change the port epmd will run on.
|
|
|
|
if not defined, epmd will use "[::]:4369"
|
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
2021-09-18 10:52:07 +00:00
|
|
|
assertions = [{
|
|
|
|
assertion = cfg.listenStream == "[::]:4369" -> config.networking.enableIPv6;
|
|
|
|
message = "epmd listens by default on ipv6, enable ipv6 or change config.services.epmd.listenStream";
|
|
|
|
}];
|
2020-04-24 23:36:52 +00:00
|
|
|
systemd.sockets.epmd = rec {
|
|
|
|
description = "Erlang Port Mapper Daemon Activation Socket";
|
|
|
|
wantedBy = [ "sockets.target" ];
|
|
|
|
before = wantedBy;
|
|
|
|
socketConfig = {
|
2021-09-18 10:52:07 +00:00
|
|
|
ListenStream = cfg.listenStream;
|
2020-04-24 23:36:52 +00:00
|
|
|
Accept = "false";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.epmd = {
|
|
|
|
description = "Erlang Port Mapper Daemon";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
requires = [ "epmd.socket" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = true;
|
|
|
|
ExecStart = "${cfg.package}/bin/epmd -systemd";
|
|
|
|
Type = "notify";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2021-02-13 14:23:35 +00:00
|
|
|
|
|
|
|
meta.maintainers = teams.beam.members;
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|