1 { config, lib, pkgs, ... }:
4 cfg = config.services.govee2mqtt;
6 meta.maintainers = with lib.maintainers; [ SuperSandro2000 ];
8 options.services.govee2mqtt = {
9 enable = lib.mkEnableOption "Govee2MQTT";
11 package = lib.mkPackageOption pkgs "govee2mqtt" { };
15 default = "govee2mqtt";
16 description = "User under which Govee2MQTT should run.";
19 group = lib.mkOption {
21 default = "govee2mqtt";
22 description = "Group under which Govee2MQTT should run.";
25 environmentFile = lib.mkOption {
26 type = lib.types.path;
27 example = "/var/lib/govee2mqtt/govee2mqtt.env";
29 Environment file as defined in {manpage}`systemd.exec(5)`.
31 See upstream documentation <https://github.com/wez/govee2mqtt/blob/main/docs/CONFIG.md>.
36 config = lib.mkIf cfg.enable {
38 groups.${cfg.group} = { };
40 description = "Govee2MQTT service user";
46 systemd.services.govee2mqtt = {
47 description = "Govee2MQTT Service";
48 wantedBy = [ "multi-user.target" ];
49 after = [ "networking.target" ];
51 CacheDirectory = "govee2mqtt";
53 "GOVEE_CACHE_DIR=/var/cache/govee2mqtt"
55 EnvironmentFile = cfg.environmentFile;
56 ExecStart = "${lib.getExe cfg.package} serve --govee-iot-key=/var/lib/govee2mqtt/iot.key --govee-iot-cert=/var/lib/govee2mqtt/iot.cert"
57 + " --amazon-root-ca=${pkgs.cacert.unbundled}/etc/ssl/certs/Amazon_Root_CA_1:66c9fcf99bf8c0a39e2f0788a43e696365bca.crt";
59 Restart = "on-failure";
60 StateDirectory = "govee2mqtt";
64 AmbientCapabilities = "";
65 CapabilityBoundingSet = "";
66 LockPersonality = true;
67 NoNewPrivileges = true;
68 PrivateDevices = true;
74 ProtectControlGroups = true;
76 ProtectHostname = true;
77 ProtectKernelLogs = true;
78 ProtectKernelModules = true;
79 ProtectKernelTunables = true;
80 ProtectProc = "invisible";
81 ProtectSystem = "strict";
83 RestrictNamespaces = true;
84 RestrictRealtime = true;
85 RestrictSUIDSGID = true;
86 SystemCallArchitectures = "native";