Skip to content

Commit 4f44d1c

Browse files
committed
Add HomeAssistant docker module
Added a new nix module which when included starts the docker container for Home Assistant
1 parent cd429cf commit 4f44d1c

File tree

4 files changed

+71
-1
lines changed

4 files changed

+71
-1
lines changed

hosts/itxserver/configuration.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ in
1616
../../users/docker.nix
1717
# All custom modules
1818
../../modules/containers/stump.nix
19+
../../modules/containers/homeassistant.nix
1920
# Any other modules
2021
inputs.sops-nix.nixosModules.sops
2122
];
@@ -83,6 +84,7 @@ in
8384

8485
environment.systemPackages = with pkgs; [
8586
btop
87+
compose2nix
8688
curl
8789
gcc
8890
git
@@ -104,6 +106,7 @@ in
104106
ports = [
105107
22
106108
8888
109+
8123
107110
];
108111
settings = {
109112
PasswordAuthentication = false;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Auto-generated using compose2nix v0.3.1. Edited.
2+
# https://www.home-assistant.io/installation/linux#docker-compose
3+
{ pkgs, lib, ... }:
4+
5+
{
6+
# Runtime
7+
virtualisation.docker = {
8+
enable = true;
9+
autoPrune.enable = true;
10+
};
11+
virtualisation.oci-containers.backend = "docker";
12+
13+
# Create persistent directory for the container data
14+
systemd.tmpfiles.rules = [
15+
"d /srv/homeassistant/config 0750 docker docker -"
16+
];
17+
18+
# Containers
19+
virtualisation.oci-containers.containers."homeassistant" = {
20+
image = "ghcr.io/home-assistant/home-assistant:stable";
21+
volumes = [
22+
"/srv/homeassistant/config:/config:rw"
23+
"/etc/localtime:/etc/localtime:ro"
24+
"/run/dbus:/run/dbus:ro"
25+
];
26+
log-driver = "journald";
27+
extraOptions = [
28+
"--network=host"
29+
"--privileged"
30+
];
31+
};
32+
systemd.services."docker-homeassistant" = {
33+
serviceConfig = {
34+
Restart = lib.mkOverride 90 "always";
35+
RestartMaxDelaySec = lib.mkOverride 90 "1m";
36+
RestartSec = lib.mkOverride 90 "100ms";
37+
RestartSteps = lib.mkOverride 90 9;
38+
};
39+
partOf = [
40+
"docker-compose-homeassistant-root.target"
41+
];
42+
wantedBy = [
43+
"docker-compose-homeassistant-root.target"
44+
];
45+
};
46+
47+
# Root service
48+
# When started, this will automatically create all resources and start
49+
# the containers. When stopped, this will teardown all resources.
50+
systemd.targets."docker-compose-homeassistant-root" = {
51+
unitConfig = {
52+
Description = "Root target generated by compose2nix.";
53+
};
54+
wantedBy = [ "multi-user.target" ];
55+
};
56+
}

modules/containers/stump.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# Create persistent directory for postgres data
1313
systemd.tmpfiles.rules = [
14-
"d /srv/stump/config 0750 stump stump -"
14+
"d /srv/stump/config 0750 docker docker -"
1515
];
1616

1717
# Containers

secrets/atuin.env.enc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ENC[AES256_GCM,data:FgMB4Fdou4FDNukmwWu4uHnFZcUfQxK2y+fbc546rLGl9FGAMpOVsOJ73SmNH+63uFe0UsJnX8CHTkUS5ahdaUzKN2JyDqqzBiSYJxKcKeiq,iv:piidfTMByoQF00IavRANhRiDeqHMhigp/yFB6L659dY=,tag:uWY6bVvO4h5YJaw7Et67cQ==,type:comment]
2+
ATUIN_DB_URI=ENC[AES256_GCM,data:MTMEj3zlnzKVJi0fczue+48nyd4YsFSM9hj/VwpJMz6+btRwKMaadU4K+hNSh9e24wO6YJ8cKe+dSbhE,iv:Q6HXAkPgHxF88di5j+LIPn0kCkpC/5n6vgUCYU0e8ww=,tag:T6PoipYT14VDOlKAaemI6A==,type:str]
3+
POSTGRES_USER=ENC[AES256_GCM,data:n42QCqY=,iv:4JN6H9Ql0n18qCtD219Uam7QJhVKLOjy9fhxMD6UxQI=,tag:RKr1aIaQqwEZm7jMPWxpfQ==,type:str]
4+
POSTGRES_PASSWORD=ENC[AES256_GCM,data:T6sWrSikarsAThDutz+ULf1SrAEMnPgjZsEkmHfD5a4=,iv:dtLynnCUMo2ynLXIuCaX1TqxFqZwcHxyMTOL916OTqw=,tag:gWS6GYmjX2ZhMGqkQiGkow==,type:str]
5+
POSTGRES_DB=ENC[AES256_GCM,data:FTAvxDtggA==,iv:IiPyHuZdILw6b/exom/u7F4v4vpnFtB0HgunulD0BjQ=,tag:NUKSOxC76XBb5KG1STaHPQ==,type:str]
6+
sops_age__list_0__map_enc=-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBpRjllNFppa3Rua2pOdnh0\naVZieFVBQ1pwZU5EVXVjUytLbmtCY2I4SkdzCkVTVjQ4eFVGRGgrdy9kaFFMaXc3\ncUZMSnFOLzBUS2hkN09MaHFCYUVFZGsKLS0tIEpnY284cGk2eWdrbG9xOFZGbTRW\nWFF5RCt1dVpOL1BDOTQ5dmVsYVNlQk0KjCp1NiHjRfJ9/2mmiQ2oXiF3toLnoiy3\nsFRflWNhGA6zjhVSb3hPmK6BYDKp0q8pjU5+q7BAQJAUYb34NO497Q==\n-----END AGE ENCRYPTED FILE-----\n
7+
sops_age__list_0__map_recipient=age1njkfdv4ayqlqak76az6ezhse8hn3gmgt9ntur2edyz3watx2xdqq3jklqm
8+
sops_lastmodified=2025-06-23T18:55:18Z
9+
sops_mac=ENC[AES256_GCM,data:KwFQkttAQ8l/sjQ0iKz09GJzXIxlsplWt7N/1jCoKUUbxcwVEIjq+oT6Ap4y96F6S9VByW/ftkKxtBv+UVROEMmrPTSKZKAM9J0CKCyahy7IhmhUe/UzzcgpQRhnmjA9W6uUUJob0YFzZ1r6moGhtnUvt3hcTv1/IlqBcxqy6DI=,iv:Ea27MTfp4I+1rHKKF6+WZEVQP+CFiyoTHrWHza/LFSw=,tag:w3Ux+y/OGS3ujS56Qi/VPw==,type:str]
10+
sops_unencrypted_suffix=_unencrypted
11+
sops_version=3.10.2

0 commit comments

Comments
 (0)