@@ -110,6 +110,17 @@ in {
110110 '';
111111 };
112112
113+ configWritable = mkOption {
114+ default = false;
115+ type = types.bool;
116+ description = ''
117+ Whether to make <filename>configuration.yaml</filename> writable.
118+ This only has an effect if <option>config</option> is set.
119+ This will allow you to edit it from Home Assistant's web interface.
120+ However, bear in mind that it will be overwritten at every start of the service.
121+ '';
122+ };
123+
113124 lovelaceConfig = mkOption {
114125 default = null;
115126 type = with types; nullOr attrs;
@@ -135,6 +146,17 @@ in {
135146 '';
136147 };
137148
149+ lovelaceConfigWritable = mkOption {
150+ default = false;
151+ type = types.bool;
152+ description = ''
153+ Whether to make <filename>ui-lovelace.yaml</filename> writable.
154+ This only has an effect if <option>lovelaceConfig</option> is set.
155+ This will allow you to edit it from Home Assistant's web interface.
156+ However, bear in mind that it will be overwritten at every start of the service.
157+ '';
158+ };
159+
138160 package = mkOption {
139161 default = pkgs.home-assistant;
140162 defaultText = "pkgs.home-assistant";
@@ -180,13 +202,17 @@ in {
180202 systemd.services.home-assistant = {
181203 description = "Home Assistant";
182204 after = [ "network.target" ];
183− preStart = optionalString (cfg.config != null) ''
205+ preStart = optionalString (cfg.config != null) (if cfg.configWritable then ''
206+ cp --no-preserve=mode ${configFile} "${cfg.configDir}/configuration.yaml"
207+ '' else ''
184208 rm -f "${cfg.configDir}/configuration.yaml"
185209 ln -s ${configFile} "${cfg.configDir}/configuration.yaml"
186− '' + optionalString (cfg.lovelaceConfig != null) ''
210+ '') + optionalString (cfg.lovelaceConfig != null) (if cfg.lovelaceConfigWritable then ''
211+ cp --no-preserve=mode ${lovelaceConfigFile} "${cfg.configDir}/ui-lovelace.yaml"
212+ '' else ''
187213 rm -f "${cfg.configDir}/ui-lovelace.yaml"
188214 ln -s ${lovelaceConfigFile} "${cfg.configDir}/ui-lovelace.yaml"
189− '';
215+ '');
190216 serviceConfig = {
191217 ExecStart = "${package}/bin/hass --config '${cfg.configDir}'";
192218 User = "hass";