build_systems / prebuild-common-x86-64-v3 (pull_request) Successful in 20s
build_systems / build-portal-1 (pull_request) Successful in 16s
test ebook search / test-ebook-search (pull_request) Successful in 1m8s
build_systems / build-bob (pull_request) Successful in 1m42s
build_systems / build-rhapsody-in-green (pull_request) Successful in 1m41s
build_systems / build-jeeves (pull_request) Successful in 1m44s
build_systems / build-brain (pull_request) Successful in 1m57s
treefmt / nix fmt (pull_request) Successful in 6s
treefmt / nix fmt (push) Successful in 3s
build_systems / prebuild-common-x86-64-v3 (push) Successful in 8s
build_systems / build-portal-1 (push) Successful in 21s
build_systems / build-bob (push) Successful in 30s
build_systems / build-brain (push) Successful in 38s
build_systems / build-rhapsody-in-green (push) Successful in 39s
test ebook search / test-ebook-search (push) Successful in 1m14s
build_systems / build-jeeves (push) Successful in 1m8s
60 lines
1.7 KiB
Nix
60 lines
1.7 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.snapshot_manager;
|
|
snapshotManager = pkgs.callPackage ../../../rust/snapshot_manager/package.nix { };
|
|
in
|
|
{
|
|
options = {
|
|
services.snapshot_manager = {
|
|
enable = lib.mkEnableOption "ZFS snapshot manager";
|
|
signalAlerts = lib.mkEnableOption "Signal failure alerts for the snapshot manager";
|
|
path = lib.mkOption {
|
|
type = lib.types.path;
|
|
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 toString 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 {
|
|
system.checks = [ snapshotManager ];
|
|
|
|
systemd = {
|
|
services.snapshot_manager = {
|
|
description = "ZFS Snapshot Manager";
|
|
requires = [ "zfs-import.target" ];
|
|
after = [ "zfs-import.target" ];
|
|
path = [ pkgs.zfs ];
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
ExecStart = "${snapshotManager}/bin/snapshot-manager ${lib.escapeShellArg cfg.path} --signal-alerts ${lib.boolToString cfg.signalAlerts}";
|
|
}
|
|
// lib.optionalAttrs (cfg.EnvironmentFile != null) {
|
|
EnvironmentFile = cfg.EnvironmentFile;
|
|
};
|
|
};
|
|
timers.snapshot_manager = {
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig = {
|
|
OnBootSec = "15m";
|
|
OnUnitActiveSec = "15m";
|
|
Unit = "snapshot_manager.service";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|