diff options
author | Ethel Morgan <eth@ethulhu.co.uk> | 2020-05-27 11:52:39 +0100 |
---|---|---|
committer | Ethel Morgan <eth@ethulhu.co.uk> | 2020-05-27 11:52:39 +0100 |
commit | e9720c891293ae8e75f9877c682ea32099b91f01 (patch) | |
tree | 5afb1f8353f58a2af69d1343e450e9caf9fe1ef1 | |
parent | cac845feb65517cf170d33ceee81372845f50fac (diff) |
create module eth.services.catbus-bridge-snapcast
-rw-r--r-- | module-list.nix | 1 | ||||
-rw-r--r-- | modules/services/catbus-bridge-snapcast.nix | 93 | ||||
-rw-r--r-- | modules/services/dlnatoad.nix | 3 |
3 files changed, 96 insertions, 1 deletions
diff --git a/module-list.nix b/module-list.nix index e152021..adcf014 100644 --- a/module-list.nix +++ b/module-list.nix @@ -3,6 +3,7 @@ ./modules/linode.nix ./modules/overlays.nix ./modules/programs/dwm.nix + ./modules/services/catbus-bridge-snapcast.nix ./modules/services/dlnatoad.nix ./modules/services/helix-player.nix ./modules/services/mosquitto.nix diff --git a/modules/services/catbus-bridge-snapcast.nix b/modules/services/catbus-bridge-snapcast.nix new file mode 100644 index 0000000..6e7badf --- /dev/null +++ b/modules/services/catbus-bridge-snapcast.nix @@ -0,0 +1,93 @@ +{ 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/modules/services/dlnatoad.nix b/modules/services/dlnatoad.nix index 90b2b39..8f50c72 100644 --- a/modules/services/dlnatoad.nix +++ b/modules/services/dlnatoad.nix @@ -28,12 +28,13 @@ in { wants = [ "network.target" ]; after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; + path = [ pkgs.ffmpeg ]; serviceConfig = { DynamicUser = true; CacheDirectory = systemdDirectoryName; - ExecStart = "${pkgs.eth.dlnatoad}/bin/dlnatoad ${concatStringsSep " " cfg.directories} --db ${cacheDirectory}/db --thumbs ${cacheDirectory}"; + ExecStart = "${pkgs.eth.dlnatoad}/bin/dlnatoad ${concatStringsSep " " cfg.directories} --db ${cacheDirectory}/db --thumbs ${cacheDirectory} --verbose"; NoNewPrivileges = true; ProtectHome = true; |