From 28b8aa8c4c9862b856164de589e4ca294fe2b194 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 30 Aug 2024 03:23:55 +0200 Subject: [PATCH] nixos/home-assistant: support extraArgs --- .../home-automation/home-assistant.nix | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/home-automation/home-assistant.nix b/nixos/modules/services/home-automation/home-assistant.nix index 963d0ba56c7b..2b9113eabdc5 100644 --- a/nixos/modules/services/home-automation/home-assistant.nix +++ b/nixos/modules/services/home-automation/home-assistant.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, utils, ... }: let inherit (lib) @@ -32,6 +32,10 @@ let unique ; + inherit (utils) + escapeSystemdExecArgs + ; + cfg = config.services.home-assistant; format = pkgs.formats.yaml {}; @@ -130,6 +134,15 @@ in { # https://github.com/home-assistant/architecture/blob/master/adr/0012-define-supported-installation-method.md#decision enable = mkEnableOption "Home Assistant. Please note that this installation method is unsupported upstream"; + extraArgs = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "--debug" ]; + description = '' + Extra arguments to pass to the hass executable. + ''; + }; + configDir = mkOption { default = "/var/lib/hass"; type = types.path; @@ -695,8 +708,14 @@ in { "zwave_js" ]; in { - ExecStart = "${package}/bin/hass --config '${cfg.configDir}'"; - ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; + ExecStart = escapeSystemdExecArgs ([ + (lib.getExe package) + "--config" cfg.configDir + ] ++ cfg.extraArgs); + ExecReload = (escapeSystemdExecArgs [ + (lib.getExe' pkgs.coreutils "kill") + "-HUP" + ]) + " $MAINPID"; User = "hass"; Group = "hass"; WorkingDirectory = cfg.configDir;