From c94e6a207cb5f72f585bac66e1d5aff9ecfbc7e9 Mon Sep 17 00:00:00 2001 From: blake Date: Sat, 4 Oct 2025 17:10:10 -0500 Subject: [PATCH] restructure dockers, add watchtower --- hosts/snowbelle/configuration.nix | 3 +++ hosts/vaniville/configuration.nix | 4 ++-- .../{ddns_docker.nix => docker/ddns.nix} | 4 ++-- modules/homelab/docker/dockers.nix | 13 +++++++++++ modules/homelab/docker/watchtower.nix | 23 +++++++++++++++++++ 5 files changed, 43 insertions(+), 4 deletions(-) rename modules/homelab/{ddns_docker.nix => docker/ddns.nix} (94%) create mode 100644 modules/homelab/docker/dockers.nix create mode 100644 modules/homelab/docker/watchtower.nix diff --git a/hosts/snowbelle/configuration.nix b/hosts/snowbelle/configuration.nix index f19fd40..ec3b8e8 100644 --- a/hosts/snowbelle/configuration.nix +++ b/hosts/snowbelle/configuration.nix @@ -21,6 +21,9 @@ zfs.enable = true; smb.enable = true; nfs.enable = true; + docker = { + watchtower.enable = true; + }; }; }; diff --git a/hosts/vaniville/configuration.nix b/hosts/vaniville/configuration.nix index e0e82d8..7887046 100644 --- a/hosts/vaniville/configuration.nix +++ b/hosts/vaniville/configuration.nix @@ -6,7 +6,7 @@ ./hardware-configuration.nix ../../users/blake/blake.nix ../../modules/system/system.nix - ../../modules/homelab/ddns_docker.nix + ../../modules/homelab/dockers/ddns.nix ]; modules = { @@ -18,7 +18,7 @@ nvidia.enable = false; }; homelab = { - ddns_docker.enable = true; + docker.ddns.enable = true; }; }; diff --git a/modules/homelab/ddns_docker.nix b/modules/homelab/docker/ddns.nix similarity index 94% rename from modules/homelab/ddns_docker.nix rename to modules/homelab/docker/ddns.nix index 8f2f845..8c60c01 100644 --- a/modules/homelab/ddns_docker.nix +++ b/modules/homelab/docker/ddns.nix @@ -2,10 +2,10 @@ { options = { - modules.homelab.ddns_docker.enable = lib.mkEnableOption "enable ddns docker"; + modules.homelab.docker.ddns.enable = lib.mkEnableOption "enable ddns docker"; }; - config = lib.mkIf config.modules.homelab.ddns_docker.enable { + config = lib.mkIf config.modules.homelab.docker.ddns.enable { let api_token = builtins.readFile /home/blake/.keyring/ddns/api_token; zone_id_blakedheld = builtins.readFile /home/blake/.keyring/ddns/zone_id_blakedheld; diff --git a/modules/homelab/docker/dockers.nix b/modules/homelab/docker/dockers.nix new file mode 100644 index 0000000..81f4873 --- /dev/null +++ b/modules/homelab/docker/dockers.nix @@ -0,0 +1,13 @@ + +{ pkgs, config, lib, ... }: + +{ + imports = [ + ./watchtowner.nix + ./ddns.nix + ]; + + modules.homelab.docker.watchtower.enable = lib.mkDefault true; + modules.homelab.docker.ddns.enable = lib.mkDefault false; + +} diff --git a/modules/homelab/docker/watchtower.nix b/modules/homelab/docker/watchtower.nix new file mode 100644 index 0000000..281ca9d --- /dev/null +++ b/modules/homelab/docker/watchtower.nix @@ -0,0 +1,23 @@ +{ pkgs, config, lib, ... }: + +{ + options = { + modules.homelab.docker.watchtower.enable = lib.mkEnableOption "enable watchtower docker"; + }; + + config = lib.mkIf config.modules.homelab.docker.watchtower.enable { + virtualisation.docker.containers.watchtower = { + image = "containrrr/watchtower"; + containerName = "watchtower"; + restartPolicy = "unless-stopped"; + environment = { + TZ = "America/Chicago"; + WATCHTOWER_INCLUDE_RESTARTING = "America/Chicago"; + WATCHTOWER_CLEANUP = "true"; + WATCHTOWER_POLL_INTERVAL = "43200"; + }; + volumes = [ "/var/run/docker.sock:/var/run/docker.sock" ]; + }; + }; +} +