From 4686a85bcd54bbae50d4f12798c111be7054e65a Mon Sep 17 00:00:00 2001 From: Richie Cahill Date: Sun, 14 Sep 2025 23:48:59 -0400 Subject: [PATCH] added EnvironmentFile to snapshot_manager --- common/global/snapshot_manager.nix | 26 +++++++++++------- systems/jeeves/default.nix | 8 +++++- systems/jeeves/snapshot_config.toml | 42 +++++++++++++++++++++++++++++ users/elise/home/programs.nix | 1 - 4 files changed, 65 insertions(+), 12 deletions(-) diff --git a/common/global/snapshot_manager.nix b/common/global/snapshot_manager.nix index ba04243..f678826 100644 --- a/common/global/snapshot_manager.nix +++ b/common/global/snapshot_manager.nix @@ -11,33 +11,39 @@ in { options = { services.snapshot_manager = { - enable = lib.mkOption { - default = true; - example = true; - description = "Whether to enable k3s-net."; - type = lib.types.bool; - }; + enable = lib.mkEnableOption "ZFS snapshot manager"; path = lib.mkOption { type = lib.types.path; - description = "Path that needs to be updated via git pull"; default = ./snapshot_config.toml; + description = "Path to the snapshot_manager TOML config."; + }; + EnvironmentFile = lib.mkOption { + type = lib.types.nullOr (lib.types.coercedTo lib.types.path lib.isString lib.types.str); + default = null; + description = '' + Single environment file for the service (e.g. /etc/snapshot-manager/env). + Use a leading "-" to ignore if missing (systemd feature). + ''; }; }; }; config = lib.mkIf cfg.enable { systemd = { - services."snapshot_manager" = { + services.snapshot_manager = { description = "ZFS Snapshot Manager"; requires = [ "zfs-import.target" ]; after = [ "zfs-import.target" ]; path = [ pkgs.zfs ]; serviceConfig = { Type = "oneshot"; - ExecStart = "${inputs.system_tools.packages.x86_64-linux.default}/bin/snapshot_manager --config-file='${cfg.path}'"; + ExecStart = "${inputs.system_tools.packages.x86_64-linux.default}/bin/snapshot_manager --config-file=${lib.escapeShellArg cfg.path}"; + } + // lib.optionalAttrs (cfg.EnvironmentFile != null) { + EnvironmentFile = cfg.EnvironmentFile; }; }; - timers."snapshot_manager" = { + timers.snapshot_manager = { wantedBy = [ "timers.target" ]; timerConfig = { OnBootSec = "15m"; diff --git a/systems/jeeves/default.nix b/systems/jeeves/default.nix index 57124fc..40e84e4 100644 --- a/systems/jeeves/default.nix +++ b/systems/jeeves/default.nix @@ -1,3 +1,6 @@ +let + vars = import ./vars.nix; +in { imports = [ ../../users/richie @@ -23,7 +26,10 @@ smartd.enable = true; - snapshot_manager.path = ./snapshot_config.toml; + snapshot_manager = { + path = ./snapshot_config.toml; + EnvironmentFile = "${vars.secrets}/services/snapshot_manager"; + }; zerotierone.joinNetworks = [ "a09acf02330d37b9" ]; }; diff --git a/systems/jeeves/snapshot_config.toml b/systems/jeeves/snapshot_config.toml index e3cc66a..3be13ed 100644 --- a/systems/jeeves/snapshot_config.toml +++ b/systems/jeeves/snapshot_config.toml @@ -51,3 +51,45 @@ monthly = 12 hourly = 12 daily = 14 monthly = 2 + +["media/services"] +15_min = 3 +hourly = 12 +daily = 14 +monthly = 2 + +["media/home_assistant"] +15_min = 3 +hourly = 12 +daily = 14 +monthly = 2 + +["scratch/qbitvpn"] +15_min = 0 +hourly = 0 +daily = 0 +monthly = 0 + +["scratch/transmission"] +15_min = 0 +hourly = 0 +daily = 0 +monthly = 0 + +["storage/qbitvpn"] +15_min = 0 +hourly = 0 +daily = 0 +monthly = 0 + +["storage/transmission"] +15_min = 0 +hourly = 0 +daily = 0 +monthly = 0 + +["storage/ollama"] +15_min = 0 +hourly = 0 +daily = 0 +monthly = 0 diff --git a/users/elise/home/programs.nix b/users/elise/home/programs.nix index d5ac41d..b1a5892 100644 --- a/users/elise/home/programs.nix +++ b/users/elise/home/programs.nix @@ -55,6 +55,5 @@ nix-tree nixfmt-rfc-style treefmt - inputs.system_tools.packages.x86_64-linux.default ]; }