1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/systems/zaatar/home-assistant.nix

92 lines
1.9 KiB
Nix
Raw Normal View History

2025-12-28 13:39:42 +01:00
{
config,
pkgs,
lib,
...
}:
let
2024-07-10 10:27:30 +02:00
port = 8123;
volumeName = "home-assistant";
2025-12-28 13:39:42 +01:00
in
{
networking.firewall.allowedTCPPorts = [ port ];
2024-07-10 10:27:30 +02:00
services.nginx.virtualHosts."home.kmein.r" = {
locations."/" = {
proxyPass = "http://127.0.0.1:${toString port}";
};
};
services.restic.backups.niveum = {
initialize = true;
repository = pkgs.lib.niveum.restic.repository;
2024-07-10 10:27:30 +02:00
timerConfig = {
OnCalendar = "daily";
RandomizedDelaySec = "1h";
};
passwordFile = config.age.secrets.restic.path;
paths = [
"/var/lib/containers/storage/volumes/${volumeName}"
];
};
age.secrets = {
di-fm-key.file = ../../secrets/di-fm-key.age;
};
2024-07-10 12:57:19 +02:00
hardware.bluetooth.enable = true;
2025-12-19 11:56:02 +01:00
systemd.services.update-containers = {
startAt = "Mon 02:00";
script = ''
images=$(${pkgs.podman}/bin/podman ps -a --format="{{.Image}}" | sort -u)
for image in $images; do
${pkgs.podman}/bin/podman pull "$image"
done
'';
serviceConfig = {
Type = "oneshot";
Restart = "on-failure";
RestartSec = "1h";
};
};
systemd.services.restart-homeassistant = {
startAt = "Tue 02:00";
script = ''
${pkgs.systemd}/bin/systemctl try-restart podman-homeassistant.service
'';
serviceConfig = {
Type = "oneshot";
};
};
virtualisation.podman = {
enable = true;
autoPrune = {
enable = true;
2025-12-28 13:39:42 +01:00
flags = [ "--all" ];
2025-12-19 11:56:02 +01:00
};
};
2024-07-10 10:27:30 +02:00
virtualisation.oci-containers = {
backend = "podman";
containers.homeassistant = {
volumes = [
"${volumeName}:/config"
2024-07-10 12:57:19 +02:00
"/run/dbus:/run/dbus:ro"
2024-07-10 10:27:30 +02:00
];
2025-12-19 15:05:54 +01:00
# needed for bluetooth
capabilities.NET_ADMIN = true;
capabilities.NET_RAW = true;
2024-07-10 10:27:30 +02:00
environment.TZ = "Europe/Berlin";
image = "ghcr.io/home-assistant/home-assistant:stable";
extraOptions = [
"--network=host"
2026-01-02 06:32:22 +01:00
"--device=/dev/ttyACM0:/dev/ttyACM0"
2024-07-10 10:27:30 +02:00
];
};
};
}