Skip to content

Commit

Permalink
whiskey auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
BCNelson committed Nov 21, 2024
1 parent 5bf4761 commit 9fcc264
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
17 changes: 8 additions & 9 deletions modules/nixos/autoUpdate/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,17 @@ in
default = null;
description = "Path to the git repository";
};
healthCheckUuid = lib.mkOption {
type = lib.types.str;
default = "";
description = "Health check configuration";
};
healthCheck = {
enable = lib.mkEnableOption "Enable health check";
url = lib.mkOption {
type = lib.types.str;
default = "";
description = "Health check URL";
};
interval = lib.mkOption {
uuid = lib.mkOption {
type = lib.types.str;
default = "5m";
description = "Health check interval";
default = "";
description = "Health check configuration";
};
};
ntfy = {
Expand Down Expand Up @@ -113,6 +108,10 @@ in
assertion = !cfg.healthCheck.enable || cfg.healthCheck.url != "";
message = "Health check URL must be set if health check is enabled";
}
{
assertion = !cfg.healthCheck.enable || cfg.healthCheck.uuid != "";
message = "Health check UUID must be set if health check is enabled";
}
{
assertion = !cfg.ntfy.enable || cfg.ntfy.topic != "";
message = "Ntfy topic must be set if ntfy is enabled";
Expand All @@ -127,7 +126,7 @@ in
enable = true;
environment = {
NTFY_TOPIC = if cfg.ntfy.enable then cfg.ntfy.topic else "";
HEALTHCHECK_UUID = if cfg.healthCheck.enable then cfg.healthCheckUuid else "";
HEALTHCHECK_UUID = if cfg.healthCheck.enable then cfg.healthCheck.uuid else "";
HEALTHCHECK_URL = if cfg.healthCheck.enable then cfg.healthCheck.url else "";
REBOOT = if cfg.reboot then "true" else "false";
CONFIG_PATH = cfg.path;
Expand Down
18 changes: 17 additions & 1 deletion nixos/whiskey/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ let
healthcheckUuid = libx.getSecret ./sensitive.nix "auto_update_healthCheck_uuid";
porkbun_api_key = libx.getSecret ./sensitive.nix "porkbun_api_key";
porkbun_api_secret = libx.getSecret ./sensitive.nix "porkbun_api_secret";
ntfy_topic = libx.getSecret ../../sensitive.nix "ntfy_topic";
in
{
imports =
[
# Include the results of the hardware scan.
./hardware-configuration.nix
(import ../_mixins/autoupdate (args // { inherit pkgs healthcheckUuid; }))
../_mixins/roles/tailscale.nix
../_mixins/roles/server
./backup.nix
Expand Down Expand Up @@ -105,4 +105,20 @@ in
zramSwap.enable = true;

networking.hostId = "9a637b7f";

services.bcnelson.autoUpdate = {
enable = true;
path = "/config";
reboot = true;
refreshInterval = "5m";
ntfy = {
enable = true;
topic = ntfy_topic;
};
healthCheck = {
enable = true;
url = "https://health.b.nel.family";
uuid = healthcheckUuid;
};
};
}

0 comments on commit 9fcc264

Please sign in to comment.