refactor: move mosquitto to tei

This commit is contained in:
arcnmx 2024-01-14 11:23:18 -08:00
parent c4dd16b101
commit 2cc89e56da
6 changed files with 51 additions and 29 deletions

31
nixos/systemd2mqtt.nix Normal file
View file

@ -0,0 +1,31 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf mkDefault;
cfg = config.services.systemd2mqtt;
in {
services.systemd2mqtt = {
enable = mkDefault true;
user = mkDefault "root";
mqtt = {
url = mkIf config.services.mosquitto.enable (
mkDefault "tcp://localhost:1883"
);
username = mkDefault "systemd";
};
};
systemd.services.systemd2mqtt = mkIf cfg.enable rec {
requires = mkIf config.services.mosquitto.enable ["mosquitto.service"];
after = requires;
serviceConfig.EnvironmentFile = [
config.sops.secrets.systemd2mqtt-env.path
];
};
sops.secrets = {
systemd2mqtt-env.owner = cfg.user;
};
}