@ -5,7 +5,9 @@ with lib;
let
cfg = config . services . home-assistant ;
configFile = pkgs . writeText " c o n f i g u r a t i o n . y a m l " ( builtins . toJSON cfg . config ) ;
configFile = pkgs . writeText " c o n f i g u r a t i o n . j s o n " ( builtins . toJSON ( if cfg . applyDefaultConfig
then ( lib . recursiveUpdate defaultConfig ( if ( isNull cfg . config ) then { } else cfg . config ) )
else cfg . config ) ) ;
availableComponents = pkgs . home-assistant . availableComponents ;
@ -38,6 +40,12 @@ let
then ( cfg . package . override { inherit extraComponents ; } )
else cfg . package ;
# If you are changing this, please update the description in applyDefaultConfig
defaultConfig = {
homeassistant . time_zone = config . time . timeZone ;
http . server_port = ( toString cfg . port ) ;
} ;
in {
meta . maintainers = with maintainers ; [ dotlambda ] ;
@ -50,6 +58,26 @@ in {
description = " T h e c o n f i g d i r e c t o r y , w h e r e y o u r < f i l e n a m e > c o n f i g u r a t i o n . y a m l < / f i l e n a m e > i s l o c a t e d . " ;
} ;
port = mkOption {
default = 8123 ;
type = types . int ;
description = " T h e p o r t o n w h i c h t o l i s t e n . " ;
} ;
applyDefaultConfig = mkOption {
default = true ;
type = types . bool ;
description = ''
Setting this option enables a few configuration options for HA based on NixOS configuration ( such as time zone ) to avoid having to manually specify configuration we already have .
< /para >
<para>
Currently one side effect of enabling this is that the <literal> http < /literal > component will be enabled .
< /para >
<para>
This only takes effect if <literal> config != null < /literal > in order to ensure that a manually managed <filename> configuration . yaml < /filename > is not overwritten .
'' ;
} ;
config = mkOption {
default = null ;
type = with types ; nullOr attrs ;
@ -110,15 +138,14 @@ in {
ln - s $ { configFile } $ { cfg . configDir } /configuration.yaml
'' ;
serviceConfig = {
ExecStart = ''
$ { package } /bin/hass - - config " ${ cfg . configDir } "
'' ;
ExecStart = " ${ package } / b i n / h a s s - - c o n f i g ' ${ cfg . configDir } ' " ;
User = " h a s s " ;
Group = " h a s s " ;
Restart = " o n - f a i l u r e " ;
ProtectSystem = " s t r i c t " ;
ReadWritePaths = " ${ cfg . configDir } " ;
PrivateTmp = true ;
RemoveIPC = true ;
} ;
path = [
" / r u n / w r a p p e r s " # needed for ping