Skip to content

Commit 31680c6

Browse files
authored
zwave-js-ui: init at 9.27.8; nixos/zwave-js-ui: init module (NixOS#336623)
2 parents 4843d1f + d7ba3b5 commit 31680c6

File tree

6 files changed

+186
-0
lines changed

6 files changed

+186
-0
lines changed

nixos/doc/manual/release-notes/rl-2505.section.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969

7070
- [crab-hole](https://github.com/LuckyTurtleDev/crab-hole), a cross platform Pi-hole clone written in Rust using hickory-dns/trust-dns. Available as [services.crab-hole](#opt-services.crab-hole.enable).
7171

72+
- [zwave-js-ui](https://zwave-js.github.io/zwave-js-ui/), a full featured Z-Wave Control Panel and MQTT Gateway. Available as [services.zwave-js-ui](#opt-services.zwave-js-ui.enable).
73+
7274
- [Amazon CloudWatch Agent](https://github.com/aws/amazon-cloudwatch-agent), the official telemetry collector for AWS CloudWatch and AWS X-Ray. Available as [services.amazon-cloudwatch-agent](options.html#opt-services.amazon-cloudwatch-agent.enable).
7375

7476
- [Bat](https://github.com/sharkdp/bat), a {manpage}`cat(1)` clone with wings. Available as [programs.bat](options.html#opt-programs.bat).

nixos/modules/module-list.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@
668668
./services/home-automation/wyoming/satellite.nix
669669
./services/home-automation/zigbee2mqtt.nix
670670
./services/home-automation/zwave-js.nix
671+
./services/home-automation/zwave-js-ui.nix
671672
./services/logging/SystemdJournal2Gelf.nix
672673
./services/logging/awstats.nix
673674
./services/logging/filebeat.nix
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
let
8+
inherit (lib)
9+
getExe
10+
mkIf
11+
mkEnableOption
12+
mkOption
13+
mkPackageOption
14+
types
15+
;
16+
cfg = config.services.zwave-js-ui;
17+
in
18+
{
19+
options.services.zwave-js-ui = {
20+
enable = mkEnableOption "zwave-js-ui";
21+
22+
package = mkPackageOption pkgs "zwave-js-ui" { };
23+
24+
serialPort = mkOption {
25+
type = types.path;
26+
description = ''
27+
Serial port for the Z-Wave controller.
28+
29+
Only used to grant permissions to the device; must be additionally configured in the application
30+
'';
31+
example = "/dev/serial/by-id/usb-example";
32+
};
33+
34+
settings = mkOption {
35+
type = types.submodule {
36+
freeformType =
37+
with types;
38+
attrsOf (
39+
nullOr (oneOf [
40+
str
41+
path
42+
package
43+
])
44+
);
45+
46+
options = {
47+
STORE_DIR = mkOption {
48+
type = types.str;
49+
default = "%S/zwave-js-ui";
50+
visible = false;
51+
readOnly = true;
52+
};
53+
54+
ZWAVEJS_EXTERNAL_CONFIG = mkOption {
55+
type = types.str;
56+
default = "%S/zwave-js-ui/.config-db";
57+
visible = false;
58+
readOnly = true;
59+
};
60+
};
61+
};
62+
63+
description = ''
64+
Extra environment variables passed to the zwave-js-ui process.
65+
66+
Check <https://zwave-js.github.io/zwave-js-ui/#/guide/env-vars> for possible options
67+
'';
68+
example = {
69+
HOST = "::";
70+
PORT = "8091";
71+
};
72+
};
73+
};
74+
config = mkIf cfg.enable {
75+
systemd.services.zwave-js-ui = {
76+
environment = cfg.settings;
77+
wantedBy = [ "multi-user.target" ];
78+
serviceConfig = {
79+
ExecStart = getExe cfg.package;
80+
RuntimeDirectory = "zwave-js-ui";
81+
StateDirectory = "zwave-js-ui";
82+
RootDirectory = "%t/zwave-js-ui";
83+
BindReadOnlyPaths = [
84+
"/nix/store"
85+
];
86+
DeviceAllow = [ cfg.serialPort ];
87+
DynamicUser = true;
88+
SupplementaryGroups = [ "dialout" ];
89+
CapabilityBoundingSet = [ "" ];
90+
RestrictAddressFamilies = "AF_INET AF_INET6";
91+
DevicePolicy = "closed";
92+
LockPersonality = true;
93+
MemoryDenyWriteExecute = false;
94+
NoNewPrivileges = true;
95+
PrivateUsers = true;
96+
PrivateTmp = true;
97+
ProtectClock = true;
98+
ProtectControlGroups = true;
99+
ProtectHome = true;
100+
ProtectHostname = true;
101+
ProtectKernelLogs = true;
102+
ProtectKernelModules = true;
103+
ProtectKernalTunables = true;
104+
ProtectProc = "invisible";
105+
ProcSubset = "pid";
106+
RemoveIPC = true;
107+
RestrictNamespaces = true;
108+
RestrictRealtime = true;
109+
RestrictSUIDSGID = true;
110+
SystemCallArchitectures = "native";
111+
SystemCallFilter = [
112+
"@system-service @pkey"
113+
"~@privileged @resources"
114+
];
115+
UMask = "0077";
116+
};
117+
};
118+
};
119+
meta.maintainers = with lib.maintainers; [ cdombroski ];
120+
}

nixos/tests/all-tests.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,4 +1204,5 @@ in {
12041204
zrepl = handleTest ./zrepl.nix {};
12051205
zsh-history = handleTest ./zsh-history.nix {};
12061206
zwave-js = handleTest ./zwave-js.nix {};
1207+
zwave-js-ui = handleTest ./zwave-js-ui.nix {};
12071208
}

nixos/tests/zwave-js-ui.nix

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import ./make-test-python.nix (
2+
{ lib, ... }:
3+
{
4+
name = "zwave-js-ui";
5+
meta.maintainers = with lib.maintainers; [ cdombroski ];
6+
7+
nodes = {
8+
machine =
9+
{ ... }:
10+
{
11+
services.zwave-js-ui = {
12+
enable = true;
13+
serialPort = "/dev/null";
14+
settings = {
15+
HOST = "::";
16+
PORT = "9999";
17+
};
18+
};
19+
};
20+
};
21+
22+
testScript = ''
23+
start_all()
24+
25+
machine.wait_for_unit("zwave-js-ui.service")
26+
machine.wait_for_open_port(9999)
27+
machine.wait_until_succeeds("journalctl --since -1m --unit zwave-js-ui --grep 'Listening on port 9999host :: protocol HTTP'")
28+
machine.wait_for_file("/var/lib/zwave-js-ui/nodes.json")
29+
'';
30+
}
31+
)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
lib,
3+
buildNpmPackage,
4+
fetchFromGitHub,
5+
nixosTests,
6+
}:
7+
8+
buildNpmPackage rec {
9+
pname = "zwave-js-ui";
10+
version = "9.27.8";
11+
12+
src = fetchFromGitHub {
13+
owner = "zwave-js";
14+
repo = "zwave-js-ui";
15+
tag = "v${version}";
16+
hash = "sha256-6Twyzt2BMozph39GMG3JghA54LYi40c1+WfSbAAO2oM=";
17+
};
18+
npmDepsHash = "sha256-2cDuRCxyn/wNgZks2Qg+iwqRX8CVRz8qVYh4ZlCR55I=";
19+
20+
passthru.tests.zwave-js-ui = nixosTests.zwave-js-ui;
21+
22+
meta = {
23+
description = "Full featured Z-Wave Control Panel and MQTT Gateway";
24+
homepage = "https://zwave-js.github.io/zwave-js-ui/";
25+
license = lib.licenses.mit;
26+
downloadPage = "https://github.com/zwave-js/zwave-js-ui/releases";
27+
changelog = "https://github.com/zwave-js/zwave-js-ui/blob/v${version}/CHANGELOG.md";
28+
mainProgram = "zwave-js-ui";
29+
maintainers = with lib.maintainers; [ cdombroski ];
30+
};
31+
}

0 commit comments

Comments
 (0)