From 58641c2cc45865c5c5f9baf54764ffc3088b6916 Mon Sep 17 00:00:00 2001 From: Magic_RB Date: Mon, 10 Jul 2023 00:50:14 +0200 Subject: [PATCH] Add new store path variable to home assistant Signed-off-by: Magic_RB --- terranix/containers/home-assistant/default.nix | 8 +++++++- terranix/containers/home-assistant/job.hcl | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/terranix/containers/home-assistant/default.nix b/terranix/containers/home-assistant/default.nix index 68c394d..e90f811 100644 --- a/terranix/containers/home-assistant/default.nix +++ b/terranix/containers/home-assistant/default.nix @@ -1,4 +1,4 @@ -{ elib, vars, ... }: +{ elib, vars, config', ... }: let inherit (elib) nfsVolume @@ -74,6 +74,12 @@ in vars = { flake_ref = "${vars.flake_host}?rev=${vars.flake_rev}&ref=${vars.flake_ref}"; flake_sha = vars.flake_sha; + store_path = builtins.toJSON (builtins.mapAttrs (_: builtins.unsafeDiscardStringContext) { + mosquitto = config'.flake.nixngConfigurations.mosquitto.config.system.build.toplevel; + postgresql = config'.flake.nixngConfigurations.homeAssistantPostgresql.config.system.build.toplevel; + homeAssistant = config'.flake.nixngConfigurations.homeAssistant.config.system.build.toplevel; + zigbee2mqtt = config'.flake.nixngConfigurations.zigbee2mqtt.config.system.build.toplevel; + }); }; }; } diff --git a/terranix/containers/home-assistant/job.hcl b/terranix/containers/home-assistant/job.hcl index eab9876..e78942f 100644 --- a/terranix/containers/home-assistant/job.hcl +++ b/terranix/containers/home-assistant/job.hcl @@ -6,6 +6,15 @@ variable "flake_sha" { type = string } +variable "store_path" { + type = object({ + mosquitto = string + postgresql = string + homeAssistant = string + zigbee2mqtt = string + }) +} + job "home-assistant" { datacenters = [ "homelab-1" ] type = "service" @@ -68,6 +77,7 @@ job "home-assistant" { config { nix_flake_ref = "${var.flake_ref}#nixngConfigurations.zigbee2mqtt.config.system.build.toplevel" nix_flake_sha = var.flake_sha + nix_flake_store_path = var.store_path.zigbee2mqtt entrypoint = [ "init" ] devices = [ @@ -147,6 +157,7 @@ EOF config { nix_flake_ref = "${var.flake_ref}#nixngConfigurations.mosquitto.config.system.build.toplevel" nix_flake_sha = var.flake_sha + nix_flake_store_path = var.store_path.mosquitto entrypoint = [ "init" ] } @@ -244,6 +255,7 @@ EOF config { nix_flake_ref = "${var.flake_ref}#nixngConfigurations.homeAssistantPostgresql.config.system.build.toplevel" nix_flake_sha = var.flake_sha + nix_flake_store_path = var.store_path.postgresql entrypoint = [ "init" ] } @@ -275,6 +287,7 @@ EOF config { nix_flake_ref = "${var.flake_ref}#nixngConfigurations.homeAssistant.config.system.build.toplevel" nix_flake_sha = var.flake_sha + nix_flake_store_path = var.store_path.homeAssistant entrypoint = [ "init" ] }