depot/nixos/modules/services/networking/epmd.nix
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

61 lines
1.8 KiB
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.services.epmd;
in
{
###### interface
options.services.epmd = {
enable = lib.mkOption {
type = lib.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 = lib.mkPackageOption pkgs "erlang" { };
listenStream = lib.mkOption
{
type = lib.types.str;
default = "[::]:4369";
description = ''
the listenStream used by the systemd socket.
see https://www.freedesktop.org/software/systemd/man/systemd.socket.html#ListenStream= for more information.
use this to change the port epmd will run on.
if not defined, epmd will use "[::]:4369"
'';
};
};
###### implementation
config = lib.mkIf cfg.enable {
assertions = [{
assertion = cfg.listenStream == "[::]:4369" -> config.networking.enableIPv6;
message = "epmd listens by default on ipv6, enable ipv6 or change config.services.epmd.listenStream";
}];
systemd.sockets.epmd = rec {
description = "Erlang Port Mapper Daemon Activation Socket";
wantedBy = [ "sockets.target" ];
before = wantedBy;
socketConfig = {
ListenStream = cfg.listenStream;
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";
};
};
};
meta.maintainers = lib.teams.beam.members;
}