style: format deconz & home-assistant configs
This commit is contained in:
parent
2be736cc24
commit
8f63ebbdca
2 changed files with 27 additions and 54 deletions
|
@ -10,8 +10,7 @@ let
|
|||
cfg = config.local.services.deconz;
|
||||
name = "deconz";
|
||||
stateDir = "/var/lib/${name}";
|
||||
in
|
||||
{
|
||||
in {
|
||||
options.local.services.deconz = {
|
||||
|
||||
enable = mkEnableOption "deCONZ, a ZigBee gateway";
|
||||
|
@ -54,10 +53,7 @@ in
|
|||
|
||||
extraOpts = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [
|
||||
"--auto-connect=1"
|
||||
"--dbg-info=1"
|
||||
];
|
||||
default = [ "--auto-connect=1" "--dbg-info=1" ];
|
||||
description = ''
|
||||
Extra command line options for deCONZ.
|
||||
These options seem undocumented, but some examples can be found here:
|
||||
|
@ -68,10 +64,8 @@ in
|
|||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [
|
||||
cfg.httpPort
|
||||
cfg.wsPort
|
||||
];
|
||||
networking.firewall.allowedTCPPorts =
|
||||
lib.mkIf cfg.openFirewall [ cfg.httpPort cfg.wsPort ];
|
||||
|
||||
systemd.services.deconz = {
|
||||
description = "deCONZ ZigBee gateway";
|
||||
|
@ -83,23 +77,20 @@ in
|
|||
rm -f ${stateDir}/.local/share/dresden-elektronik/deCONZ/zcldb.txt
|
||||
'';
|
||||
serviceConfig = {
|
||||
ExecStart =
|
||||
"${cfg.package}/bin/deCONZ"
|
||||
+ " -platform minimal"
|
||||
ExecStart = "${cfg.package}/bin/deCONZ" + " -platform minimal"
|
||||
+ " --http-port=${toString cfg.httpPort}"
|
||||
+ " --ws-port=${toString cfg.wsPort}"
|
||||
+ (if cfg.device != "" then " --dev=${cfg.device}" else "")
|
||||
+ " " + (lib.concatStringsSep " " cfg.extraOpts);
|
||||
+ (if cfg.device != "" then " --dev=${cfg.device}" else "") + " "
|
||||
+ (lib.concatStringsSep " " cfg.extraOpts);
|
||||
Restart = "on-failure";
|
||||
AmbientCapabilities =
|
||||
let
|
||||
# ref. upstream deconz.service
|
||||
caps = lib.optionals (cfg.httpPort < 1024 || cfg.wsPort < 1024) [ "CAP_NET_BIND_SERVICE" ]
|
||||
++ lib.optionals (cfg.allowRebootSystem) [ "CAP_SYS_BOOT" ]
|
||||
++ lib.optionals (cfg.allowRestartService) [ "CAP_KILL" ]
|
||||
++ lib.optionals (cfg.allowSetSystemTime) [ "CAP_SYS_TIME" ];
|
||||
in
|
||||
lib.concatStringsSep " " caps;
|
||||
AmbientCapabilities = let
|
||||
# ref. upstream deconz.service
|
||||
caps = lib.optionals (cfg.httpPort < 1024 || cfg.wsPort < 1024)
|
||||
[ "CAP_NET_BIND_SERVICE" ]
|
||||
++ lib.optionals (cfg.allowRebootSystem) [ "CAP_SYS_BOOT" ]
|
||||
++ lib.optionals (cfg.allowRestartService) [ "CAP_KILL" ]
|
||||
++ lib.optionals (cfg.allowSetSystemTime) [ "CAP_SYS_TIME" ];
|
||||
in lib.concatStringsSep " " caps;
|
||||
UMask = "0027";
|
||||
User = name;
|
||||
StateDirectory = name;
|
||||
|
@ -115,9 +106,9 @@ in
|
|||
group = name;
|
||||
isSystemUser = true;
|
||||
home = stateDir;
|
||||
extraGroups = [ "dialout" ]; # for access to /dev/ttyACM0 (ConBee)
|
||||
extraGroups = [ "dialout" ]; # for access to /dev/ttyACM0 (ConBee)
|
||||
};
|
||||
|
||||
users.groups.deconz = {};
|
||||
users.groups.deconz = { };
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue