-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
87 lines (61 loc) · 1.88 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
description = "Packaging EMQX";
inputs = {
nixpkgs.url = "github:imsl/nixpkgs/rebar3-fixes";
};
outputs = { self, nixpkgs }: {
packages.x86_64-linux =
let
inherit (nixpkgs.legacyPackages.x86_64-linux)
beamPackages
cacert
callPackage
fetchFromGitHub
fetchgit
gitMinimal
testers
;
inherit (beamPackages)
rebar3
rebar3Relx
rebar3WithPlugins
fetchRebar3Deps
;
in rec {
rebar3-with-nix = rebar3WithPlugins {
globalPlugins = [ beamPackages.rebar3-nix ];
};
emqx = callPackage ./nixpkgs/emqx {};
emqxTest = testers.nixosTest {
name = "emqx";
nodes = {
server = { config, lib, pkgs, ... }: {
imports = [ ./nixos/emqx.nix ];
networking.firewall.allowedTCPPorts = [ 1883 ];
services.emqx = {
enable = true;
package = emqx;
nodeName = "emqx@127.0.0.1";
logConsoleHandler.level = "notice";
};
};
client = { pkgs, ... }: {
environment.systemPackages = with pkgs; [ mosquitto ];
};
};
testScript = ''
start_all()
server.wait_for_unit("emqx.service")
# Verify the MQTT listener comes up
server.wait_for_open_port(1883)
# Verify the EMQX web UI listener comes up
server.wait_for_open_port(18083)
# Send a retained message to the EMQX broker
client.succeed("mosquitto_pub -h server -r -t test -m test")
# Receive the same message in a separate session
client.succeed("mosquitto_sub -h server -W 5 -C 1 -t test")
'';
};
};
};
}