about summary refs log tree commit diff
path: root/nixos/modules/services/misc
diff options
context:
space:
mode:
authorRobert Schütz <robert.schuetz@stud.uni-heidelberg.de>2019-02-03 12:45:52 +0100
committerRobert Schütz <robert.schuetz@stud.uni-heidelberg.de>2019-02-03 13:08:11 +0100
commitf85453f060b4756a3d55c2d3a6563be19f41dfe6 (patch)
treeb331a7d98c10abe04073dc41789321ca6264326f /nixos/modules/services/misc
parentf908f6c9827288cdd0dda84d28738d300377a8b2 (diff)
downloadnixlib-f85453f060b4756a3d55c2d3a6563be19f41dfe6.tar
nixlib-f85453f060b4756a3d55c2d3a6563be19f41dfe6.tar.gz
nixlib-f85453f060b4756a3d55c2d3a6563be19f41dfe6.tar.bz2
nixlib-f85453f060b4756a3d55c2d3a6563be19f41dfe6.tar.lz
nixlib-f85453f060b4756a3d55c2d3a6563be19f41dfe6.tar.xz
nixlib-f85453f060b4756a3d55c2d3a6563be19f41dfe6.tar.zst
nixlib-f85453f060b4756a3d55c2d3a6563be19f41dfe6.zip
nixos/home-assistant: add configWritable option
Diffstat (limited to 'nixos/modules/services/misc')
-rw-r--r--nixos/modules/services/misc/home-assistant.nix32
1 files changed, 29 insertions, 3 deletions
diff --git a/nixos/modules/services/misc/home-assistant.nix b/nixos/modules/services/misc/home-assistant.nix
index 628dd7c39b14..4eabda1d4188 100644
--- a/nixos/modules/services/misc/home-assistant.nix
+++ b/nixos/modules/services/misc/home-assistant.nix
@@ -110,6 +110,17 @@ in {
       '';
     };
 
+    configWritable = mkOption {
+      default = false;
+      type = types.bool;
+      description = ''
+        Whether to make <filename>configuration.yaml</filename> writable.
+        This only has an effect if <option>config</option> is set.
+        This will allow you to edit it from Home Assistant's web interface.
+        However, bear in mind that it will be overwritten at every start of the service.
+      '';
+    };
+
     lovelaceConfig = mkOption {
       default = null;
       type = with types; nullOr attrs;
@@ -135,6 +146,17 @@ in {
       '';
     };
 
+    lovelaceConfigWritable = mkOption {
+      default = false;
+      type = types.bool;
+      description = ''
+        Whether to make <filename>ui-lovelace.yaml</filename> writable.
+        This only has an effect if <option>lovelaceConfig</option> is set.
+        This will allow you to edit it from Home Assistant's web interface.
+        However, bear in mind that it will be overwritten at every start of the service.
+      '';
+    };
+
     package = mkOption {
       default = pkgs.home-assistant;
       defaultText = "pkgs.home-assistant";
@@ -180,13 +202,17 @@ in {
     systemd.services.home-assistant = {
       description = "Home Assistant";
       after = [ "network.target" ];
-      preStart = optionalString (cfg.config != null) ''
+      preStart = optionalString (cfg.config != null) (if cfg.configWritable then ''
+        cp --no-preserve=mode ${configFile} "${cfg.configDir}/configuration.yaml"
+      '' else ''
         rm -f "${cfg.configDir}/configuration.yaml"
         ln -s ${configFile} "${cfg.configDir}/configuration.yaml"
-      '' + optionalString (cfg.lovelaceConfig != null) ''
+      '') + optionalString (cfg.lovelaceConfig != null) (if cfg.lovelaceConfigWritable then ''
+        cp --no-preserve=mode ${lovelaceConfigFile} "${cfg.configDir}/ui-lovelace.yaml"
+      '' else ''
         rm -f "${cfg.configDir}/ui-lovelace.yaml"
         ln -s ${lovelaceConfigFile} "${cfg.configDir}/ui-lovelace.yaml"
-      '';
+      '');
       serviceConfig = {
         ExecStart = "${package}/bin/hass --config '${cfg.configDir}'";
         User = "hass";