2018-01-25 20:28:58 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.epmd;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options.services.epmd = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.erlang;
|
2021-10-03 18:06:03 +02:00
|
|
|
defaultText = literalExpression "pkgs.erlang";
|
2018-01-25 20:28:58 +01:00
|
|
|
description = ''
|
|
|
|
The Erlang package to use to get epmd binary. That way you can re-use
|
|
|
|
an Erlang runtime that is already installed for other purposes.
|
|
|
|
'';
|
|
|
|
};
|
2021-08-27 09:47:11 +02:00
|
|
|
listenStream = mkOption
|
|
|
|
{
|
|
|
|
type = types.str;
|
2021-08-30 13:49:47 +02:00
|
|
|
default = "[::]:4369";
|
2021-08-27 09:47:11 +02:00
|
|
|
description = ''
|
|
|
|
the listenStream used by the systemd socket.
|
|
|
|
see https://www.freedesktop.org/software/systemd/man/systemd.socket.html#ListenStream= for more informations.
|
|
|
|
use this to change the port epmd will run on.
|
|
|
|
if not defined, epmd will use "[::]:4369"
|
|
|
|
'';
|
|
|
|
};
|
2018-01-25 20:28:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
2021-08-27 09:47:11 +02:00
|
|
|
assertions = [{
|
2021-08-30 13:49:47 +02:00
|
|
|
assertion = cfg.listenStream == "[::]:4369" -> config.networking.enableIPv6;
|
2021-08-27 09:47:11 +02:00
|
|
|
message = "epmd listens by default on ipv6, enable ipv6 or change config.services.epmd.listenStream";
|
|
|
|
}];
|
2018-01-25 20:28:58 +01:00
|
|
|
systemd.sockets.epmd = rec {
|
|
|
|
description = "Erlang Port Mapper Daemon Activation Socket";
|
|
|
|
wantedBy = [ "sockets.target" ];
|
|
|
|
before = wantedBy;
|
|
|
|
socketConfig = {
|
2021-08-30 13:49:47 +02:00
|
|
|
ListenStream = cfg.listenStream;
|
2018-01-25 20:28:58 +01: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-01-23 21:25:40 +01:00
|
|
|
|
|
|
|
meta.maintainers = teams.beam.members;
|
2018-01-25 20:28:58 +01:00
|
|
|
}
|