diff --git a/ops/nixos/lib/seaweedfs.nix b/ops/nixos/lib/seaweedfs.nix index 58c5c33007..bfbc47ab06 100644 --- a/ops/nixos/lib/seaweedfs.nix +++ b/ops/nixos/lib/seaweedfs.nix @@ -138,6 +138,30 @@ in { default = {}; }; }; + + sync = lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule { + options = { + package = lib.mkOption { + type = lib.types.package; + default = cfg.package; + }; + + earlyOptions = lib.mkOption { + type = lib.types.submodule { + freeformType = commandLineType; + }; + default = {}; + }; + options = lib.mkOption { + type = lib.types.submodule { + freeformType = commandLineType; + }; + default = {}; + }; + }; + }); + }; }; config = lib.mkMerge [{ @@ -226,5 +250,22 @@ in { Restart = "always"; }; }; - })]; + }) { + systemd.services = lib.mapAttrs' (k: v: lib.nameValuePair "seaweedfs-sync-${k}" { + wantedBy = [ "seaweedfs.target" ]; + unitConfig = { + StartLimitIntervalSec = "0"; + }; + serviceConfig = { + ExecStart = "${v.package}/bin/weed ${makeCommandLine v.earlyOptions} filer.sync ${makeCommandLine v.options}"; + User = "seaweedfs-sync"; + DynamicUser = true; + Restart = "always"; + + RestartSec = "100ms"; + RestartSteps = 10; + RestartMaxDelaySec = "1min"; + }; + }) cfg.sync; + }]; } diff --git a/ops/nixos/totoro/default.nix b/ops/nixos/totoro/default.nix index c41845edfd..36a4203a73 100644 --- a/ops/nixos/totoro/default.nix +++ b/ops/nixos/totoro/default.nix @@ -627,6 +627,10 @@ in { master = "[${config.my.ip.tailscale6}]:21000"; }; }; + sync.rexxar.options = { + a = "rexxar.int.as205479.net:21010"; + b = "totoro.int.as205479.net:21010"; + }; }; system.stateVersion = "22.11";