nixos zwave?

This commit is contained in:
Chris Dombroski 2024-08-20 21:49:04 -04:00
parent 12df3009d1
commit c2a3c18ef5
5 changed files with 70 additions and 3 deletions

View file

@ -11,6 +11,7 @@
};
nixpkgs.overlays = [
(import ../../overlays/recyclarr.nix)
(import ../../overlays/zwave-js-ui.nix)
];
system.autoUpgrade = {
enable = true;

30
modules/zwave-js-ui.nix Normal file
View file

@ -0,0 +1,30 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkEnableOption mkOption types;
cfg = config.services.zwave-js-ui;
in
{
options.services.zwave-js-ui = {
enable = mkEnableOption "zwave-js-ui";
store = mkOption {
type = types.path;
default = "/var/lib/zwave-js-ui";
description = ''
Where zwave-js-ui information will be stored
'';
};
};
config = mkIf cfg.enable {
assertions = [{
assertion = !config.services.zwave-js.enable;
message = "zwave-js-ui conflicts with zwave-js";
}];
systemd.services.zwave-js-ui = {
environment = {
STORE_DIR = cfg.store;
ZWAVEJS_EXTERNAL_CONFIG = "${cfg.store}/.config-db";
};
script = "${pkgs.zwave-js-ui}/bin/zwave-js-ui";
};
};
}

4
overlays/zwave-js-ui.nix Normal file
View file

@ -0,0 +1,4 @@
final: prev:
{
zwave-js-ui = ( prev.callPackage ../pkgs/zwave-js-ui.nix {} );
}

21
pkgs/zwave-js-ui.nix Normal file
View file

@ -0,0 +1,21 @@
{ lib, buildNpmPackage, fetchFromGitHub }:
buildNpmPackage rec {
pname = "zwave-js-ui";
version = "9.17.0";
src = fetchFromGitHub {
owner = "zwave-js";
repo = pname;
rev = "v${version}";
hash = "sha256-GCBVRjDpiC8WhPHFwKnzyO5I09TDx3IbxpUZvwDu2u0=";
};
npmDepsHash = "sha256-YtHiBVz2eyHyJkr4K1NZXVZKdZTmdGMDFGpEC0QUCMU=";
meta = {
description = "Full featured Z-Wave Control Panel and MQTT Gateway.";
homepage = "https://zwave-js.github.io/zwave-js-ui/";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [cdombroski];
};
}

View file

@ -147,15 +147,26 @@
extraOptions = [ "--pull=newer" "--network=www" ];
};
zwave-js-ui = {
image = "docker.io/zwavejs/zwave-js-ui:latest";
image = "my-zwave-js-ui:latest";
imageFile = pkgs.dockerTools.buildImage {
name = "my-zwave-js-ui";
tag = "latest";
copyToRoot = with pkgs; [cacert];
config.Cmd = [ "${pkgs.zwave-js-ui}/bin/zwave-js-ui" ];
};
volumes = [ "zwave-config:/usr/src/app/store" ];
environment.TZ = "America/New_York";
environment = {
TZ = "America/New_York";
STORE_DIR = "/usr/src/app/store";
ZWAVEJS_EXTERNAL_CONFIG = "/usr/src/app/store/.config-db";
};
labels = {
swag = "enable";
swag_url = "zwave.icanttype.org";
swag_port = "8091";
};
extraOptions =
[ "--pull=newer" "--network=www" "--device=/dev/ttyACM0:/dev/zwave" ];
[ "--network=www" "--device=/dev/ttyACM0:/dev/zwave" ];
};
homeassistant = {
image = "lscr.io/linuxserver/homeassistant:latest";