summaryrefslogtreecommitdiff
path: root/nixos
diff options
context:
space:
mode:
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix2
-rw-r--r--nixos/modules/services/catbus-bridge-snapcast.nix93
-rw-r--r--nixos/modules/services/catbus-snapcast.nix67
3 files changed, 68 insertions, 94 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 3f80aac..83566f5 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -6,9 +6,9 @@
./programs/dwm.nix
./services/ambience.nix
./services/catbus-actuator-wakeonlan.nix
- ./services/catbus-bridge-snapcast.nix
./services/catbus-lgtv.nix
./services/catbus-observer-networkpresence.nix
+ ./services/catbus-snapcast.nix
./services/dlnatoad.nix
./services/helix-directory-jackalope.nix
./services/helix-directory.nix
diff --git a/nixos/modules/services/catbus-bridge-snapcast.nix b/nixos/modules/services/catbus-bridge-snapcast.nix
deleted file mode 100644
index 6e7badf..0000000
--- a/nixos/modules/services/catbus-bridge-snapcast.nix
+++ /dev/null
@@ -1,93 +0,0 @@
-{ config, lib, pkgs, ... }:
-with lib;
-
-let
-
- cfg = config.eth.services.catbus-bridge-snapcast;
-
- configJSON = pkgs.writeText "config.json" ''
- {
- "broker_host": "${cfg.mqttBroker.host}",
- "broker_port": ${toString cfg.mqttBroker.port},
-
- "snapserver_host": "${cfg.snapserver.host}",
- "snapserver_port": ${toString cfg.snapserver.port},
-
- "topic_input": "${cfg.topics.input}",
-
- "snapcast_group_id": "${cfg.snapcastGroupID}"
- }
- '';
-
-in {
-
- options.eth.services.catbus-bridge-snapcast = {
-
- enable = mkEnableOption "Whether to enable the Catbus Snapcast bridge";
-
- 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;
- };
- };
-
- snapserver = {
- host = mkOption {
- type = types.str;
- description = "Host of the Snapserver.";
- example = "localhost";
- };
- port = mkOption {
- type = types.int;
- description = "Port of the Snapserver.";
- default = 1705;
- };
- };
-
- topics = {
- input = mkOption {
- type = types.str;
- description = "MQTT topic for controlling the Snapcast group input";
- example = "home/house/speakers/input_enum";
- };
- };
-
- snapcastGroupID = mkOption {
- type = types.str;
- description = "The ID of the Snapcast group to control";
- example = "352aba34-0ba8-8a4e-9f46-cb634b1c800a";
- };
- };
-
-
- config = mkIf cfg.enable {
- systemd.services.catbus-bridge-snapcast = {
- enable = true;
- description = "Control Snapcast via Catbus";
- wants = [ "network.target" ];
- after = [ "network.target" ];
- wantedBy = [ "multi-user.target" ];
- serviceConfig = {
- DynamicUser = true;
-
- ExecStart = "${pkgs.eth.catbus-snapcast}/bin/catbus-bridge-snapcast --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-snapcast.nix b/nixos/modules/services/catbus-snapcast.nix
new file mode 100644
index 0000000..8ee8301
--- /dev/null
+++ b/nixos/modules/services/catbus-snapcast.nix
@@ -0,0 +1,67 @@
+{ config, lib, pkgs, ... }:
+with lib;
+
+let
+
+ cfg = config.eth.services.catbus-snapcast;
+
+ configJSON = pkgs.writeText "config.json" (builtins.toJSON {
+ mqttBroker = cfg.mqttBroker;
+ topics = cfg.topics;
+ snapcast = cfg.snapcast;
+ });
+
+in {
+
+ options.eth.services.catbus-snapcast = {
+
+ enable = mkEnableOption "Whether to enable the Catbus Snapcast bridge";
+
+ mqttBroker = mkOption {
+ type = types.str;
+ description = "URL of the MQTT broker.";
+ example = "tcp://broker.local:1883";
+ };
+
+ topics = {
+ input = mkOption {
+ type = types.str;
+ description = "MQTT topic for controlling the Snapcast group input";
+ example = "home/house/speakers/input_enum";
+ };
+ };
+
+ snapcast = {
+ groupId = mkOption {
+ type = types.str;
+ description = "The ID of the Snapcast group to control";
+ example = "352aba34-0ba8-8a4e-9f46-cb634b1c800a";
+ };
+ };
+ };
+
+
+ config = mkIf cfg.enable {
+ systemd.services.catbus-snapcast-bridge = {
+ enable = true;
+ description = "Control Snapcast via Catbus";
+ wants = [ "network.target" ];
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ DynamicUser = true;
+
+ ExecStart = "${pkgs.eth.catbus-snapcast}/bin/catbus-bridge-snapcast --config-path ${configJSON}";
+
+ NoNewPrivileges = true;
+ ProtectKernelTunables = true;
+ ProtectControlGroups = true;
+ ProtectKernelModules = true;
+ RestrictAddressFamilies = "AF_INET AF_INET6";
+ RestrictNamespaces = true;
+ };
+ };
+ };
+
+}
+