Skip to content

Instantly share code, notes, and snippets.

@lheckemann
Created September 21, 2021 20:15
Show Gist options
  • Select an option

  • Save lheckemann/6c72eb2d2afbebdfee6abe328afe1a4c to your computer and use it in GitHub Desktop.

Select an option

Save lheckemann/6c72eb2d2afbebdfee6abe328afe1a4c to your computer and use it in GitHub Desktop.

Revisions

  1. lheckemann created this gist Sep 21, 2021.
    52 changes: 52 additions & 0 deletions hass-podman.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    { pkgs, config, lib, ... }:
    let
    hassConfig = (pkgs.formats.yaml {}).generate "home-assistant-configuration" {
    config = {};
    frontend = {};
    history = {};
    image = {};
    input_boolean = {};
    input_datetime = {
    good_morning = {
    name = "LED Alarm";
    has_time = true;
    };
    };
    input_number = {};
    input_select = {};
    logbook = {};
    mobile_app = {};
    prometheus = {};
    person = {};
    ssdp = {};
    sun = {};
    system_health = {};
    updater = {};
    zeroconf = {};
    zone = {};

    http = {
    use_x_forwarded_for = true;
    trusted_proxies = config.vpn.hosts.sosiego.vpnIPs;
    };

    group = {};
    automation = import ./hass/automations.nix {inherit lib;};
    script = {};
    scene = {};
    };
    in {
    virtualisation.oci-containers.backend = "podman";
    virtualisation.oci-containers.containers.home-assistant = {
    image = "docker.io/homeassistant/home-assistant";
    volumes = [
    "/var/lib/hass:/config"
    "/etc/localtime:/etc/localtime:ro"
    "${hassConfig}:/config/configuration.yaml:ro"
    ];
    extraOptions = ["--net=host" "--pull=always"];
    };
    systemd.services.podman-home-assistant.serviceConfig.RestartSec = "10s";
    # Hack to get podman working with zfs
    systemd.services.podman-home-assistant.path = [ config.boot.zfs.package ];
    }