summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nixos/modules/module-list.nix3
-rw-r--r--nixos/modules/services/catbus-lgtv.nix (renamed from nixos/modules/services/catbus-actuator-lgtv.nix)28
-rw-r--r--nixos/modules/services/catbus-observer-lgtv.nix108
3 files changed, 25 insertions, 114 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index a5e7dcc..3f80aac 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -5,10 +5,9 @@
./overlays.nix
./programs/dwm.nix
./services/ambience.nix
- ./services/catbus-actuator-lgtv.nix
./services/catbus-actuator-wakeonlan.nix
./services/catbus-bridge-snapcast.nix
- ./services/catbus-observer-lgtv.nix
+ ./services/catbus-lgtv.nix
./services/catbus-observer-networkpresence.nix
./services/dlnatoad.nix
./services/helix-directory-jackalope.nix
diff --git a/nixos/modules/services/catbus-actuator-lgtv.nix b/nixos/modules/services/catbus-lgtv.nix
index 051da5b..8011004 100644
--- a/nixos/modules/services/catbus-actuator-lgtv.nix
+++ b/nixos/modules/services/catbus-lgtv.nix
@@ -3,7 +3,7 @@ with lib;
let
- cfg = config.eth.services.catbus-actuator-lgtv;
+ cfg = config.eth.services.catbus-lgtv;
configJSON = pkgs.writeText "config.json" (builtins.toJSON {
mqttBroker = "tcp://${cfg.mqttBroker.host}:${toString cfg.mqttBroker.port}";
@@ -19,9 +19,9 @@ let
in {
- options.eth.services.catbus-actuator-lgtv = {
+ options.eth.services.catbus-lgtv = {
- enable = mkEnableOption "Whether to enable the Catbus WebOS LGTV actuator";
+ enable = mkEnableOption "Whether to enable the Catbus WebOS LGTV daemons.";
mqttBroker = {
host = mkOption {
@@ -83,7 +83,7 @@ in {
config = mkIf cfg.enable {
- systemd.services.catbus-actuator-lgtv = {
+ systemd.services.catbus-lgtv-actuator = {
enable = true;
description = "Control a WebOS LGTV via Catbus";
wants = [ "network.target" ];
@@ -102,6 +102,26 @@ in {
RestrictNamespaces = true;
};
};
+
+ systemd.services.catbus-lgtv-observer = {
+ enable = true;
+ description = "Observe a WebOS LGTV via Catbus";
+ wants = [ "network.target" ];
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ DynamicUser = true;
+
+ ExecStart = "${pkgs.eth.catbus-lgtv}/bin/catbus-observer-lgtv --config-path ${configJSON}";
+
+ NoNewPrivileges = true;
+ ProtectKernelTunables = true;
+ ProtectControlGroups = true;
+ ProtectKernelModules = true;
+ RestrictAddressFamilies = "AF_INET AF_INET6";
+ RestrictNamespaces = true;
+ };
+ };
};
}
diff --git a/nixos/modules/services/catbus-observer-lgtv.nix b/nixos/modules/services/catbus-observer-lgtv.nix
deleted file mode 100644
index 9e727f3..0000000
--- a/nixos/modules/services/catbus-observer-lgtv.nix
+++ /dev/null
@@ -1,108 +0,0 @@
-{ config, lib, pkgs, ... }:
-with lib;
-
-let
-
- cfg = config.eth.services.catbus-observer-lgtv;
-
- configJSON = pkgs.writeText "config.json" (builtins.toJSON {
- mqttBroker = "tcp://${cfg.mqttBroker.host}:${toString cfg.mqttBroker.port}";
- apps = cfg.apps;
- topics = {
- app = cfg.topics.input;
- appValues = cfg.topics.inputValues;
- power = cfg.topics.power;
- volume = cfg.topics.volume;
- };
- tv = cfg.tv;
- });
-
-in {
-
- options.eth.services.catbus-observer-lgtv = {
-
- enable = mkEnableOption "Whether to enable the Catbus WebOS LGTV observer";
-
- mqttBroker = {
- host = mkOption {
- type = types.str;
- description = "Host of the MQTT broker.";
- example = "localhost";
- };
- port = mkOption {
- type = types.int;
- description = "Port of the MQTT broker.";
- default = 1883;
- };
- };
-
- tv = {
- host = mkOption {
- type = types.str;
- default = "";
- description = "TV host";
- example = "192.168.16.69";
- };
- key = mkOption {
- type = types.str;
- default = "";
- description = "A key generated from pkgs.eth.catbus-lgtv/bin/generate-key";
- example = "25561897424495c18042fef5ebe8d7fc";
- };
- };
-
- topics = {
- input = mkOption {
- type = types.str;
- description = "MQTT topic for controlling the TV's input";
- example = "home/living-room/tv/app_enum";
- };
- inputValues = mkOption {
- type = types.str;
- description = "MQTT topic for exporting the TV's apps";
- example = "home/living-room/tv/app_enum/values";
- };
- power = mkOption {
- type = types.str;
- description = "MQTT topic for controlling the TV's power";
- example = "home/living-room/tv/power";
- };
- volume = mkOption {
- type = types.str;
- description = "MQTT topic for controlling the TV's volume";
- example = "home/living-room/tv/volume_percent";
- };
- };
-
- apps = mkOption {
- type = types.attrsOf types.str;
- example = { PS4 = "com.webos.input.hdmi1"; };
- description = "A set of friendly app names and their corresponding IDs";
- };
- };
-
-
- config = mkIf cfg.enable {
- systemd.services.catbus-observer-lgtv = {
- enable = true;
- description = "Observe a WebOS LGTV via Catbus";
- wants = [ "network.target" ];
- after = [ "network.target" ];
- wantedBy = [ "multi-user.target" ];
- serviceConfig = {
- DynamicUser = true;
-
- ExecStart = "${pkgs.eth.catbus-lgtv}/bin/catbus-observer-lgtv --config-path ${configJSON}";
-
- NoNewPrivileges = true;
- ProtectKernelTunables = true;
- ProtectControlGroups = true;
- ProtectKernelModules = true;
- RestrictAddressFamilies = "AF_INET AF_INET6";
- RestrictNamespaces = true;
- };
- };
- };
-
-}
-