mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
refactor: move mosquitto to tei
This commit is contained in:
parent
c4dd16b101
commit
2cc89e56da
6 changed files with 51 additions and 29 deletions
31
nixos/systemd2mqtt.nix
Normal file
31
nixos/systemd2mqtt.nix
Normal 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;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue