Skip to content

Commit

Permalink
Merge pull request #969 from alskipp/rabbitmq_config_node_name
Browse files Browse the repository at this point in the history
Allow setting rabbitMQ nodeName
  • Loading branch information
domenkozar authored Feb 3, 2024
2 parents e4019e1 + 9479b99 commit bad7870
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
14 changes: 14 additions & 0 deletions examples/rabbitmq/.test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -ex

devenv up &
DEVENV_PID=$!
export DEVENV_PID

devenv_stop() {
pkill -P "$DEVENV_PID"
}

trap devenv_stop EXIT

timeout 20 bash -c 'until rabbitmqctl -q status 2>/dev/null; do sleep 0.5; done'
8 changes: 8 additions & 0 deletions examples/rabbitmq/devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ pkgs, ... }:

{
services.rabbitmq = {
enable = true;
managementPlugin = { enable = true; };
};
}
3 changes: 3 additions & 0 deletions examples/rabbitmq/devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
inputs:
nixpkgs:
url: github:NixOS/nixpkgs/nixpkgs-unstable
25 changes: 21 additions & 4 deletions src/modules/services/rabbitmq.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ let
[ ${concatStringsSep "," cfg.plugins} ].
'';
in

{
imports = [
(lib.mkRenamedOptionModule [ "rabbitmq" "enable" ] [ "services" "rabbitmq" "enable" ])
(lib.mkRenamedOptionModule [ "rabbitmq" "enable" ] [
"services"
"rabbitmq"
"enable"
])
];

options.services.rabbitmq = {
Expand Down Expand Up @@ -64,6 +67,19 @@ in
type = types.port;
};

nodeName = mkOption {
default = "rabbit@localhost";
type = types.str;
description = ''
The name of the RabbitMQ node. This is used to identify
the node in a cluster. If you are running multiple
RabbitMQ nodes on the same machine, you must give each
node a unique name. The name must be of the form
`name@host`, where `name` is an arbitrary name and
`host` is the domain name of the host.
'';
};

cookie = mkOption {
default = "";
type = types.str;
Expand Down Expand Up @@ -133,7 +149,8 @@ in
"management.tcp.ip" = cfg.listenAddress;
};

services.rabbitmq.plugins = optional cfg.managementPlugin.enable "rabbitmq_management";
services.rabbitmq.plugins =
optional cfg.managementPlugin.enable "rabbitmq_management";

env.RABBITMQ_DATA_DIR = config.env.DEVENV_STATE + "/rabbitmq";
env.RABBITMQ_MNESIA_BASE = config.env.RABBITMQ_DATA_DIR + "/mnesia";
Expand All @@ -142,7 +159,7 @@ in
env.RABBITMQ_CONFIG_FILE = config_file;
env.RABBITMQ_PLUGINS_DIR = concatStringsSep ":" cfg.pluginDirs;
env.RABBITMQ_ENABLED_PLUGINS_FILE = plugin_file;
env.RABBITMQ_NODENAME = "rabbit@localhost";
env.RABBITMQ_NODENAME = cfg.nodeName;
env.RABBITMQ_HOST = cfg.listenAddress;
env.ERL_EPMD_ADDRESS = cfg.listenAddress;

Expand Down

0 comments on commit bad7870

Please sign in to comment.