{ config, pkgs, ... }: let domain = "push.${config.customOps.domain.fqdn}"; port = 2586; redisPort = 6369; endpointPort = 443; autopush = pkgs.autopush-rs; in { sops.secrets = { "autopush/autoconnect" = { owner = "autopush"; }; "autopush/autoendpoint" = { owner = "autopush"; }; }; users.users."autopush" = { group = "autopush"; useDefaultShell = true; }; environment.systemPackages = [autopush]; services.redis.servers."autopush" = { enable = true; port = redisPort; }; systemd.services = { autopush-autoconnect = { environment = { AUTOCONNECT__DB_DSN = "redis://127.0.0.1:${redisPort}"; AUTOCONNECT__ENDPOINT_SCHEME = "https"; AUTOCONNECT__ENDPOINT_HOSTNAME = "update.${domain}"; AUTOCONNECT__ENDPOINT_PORT = endpointPort; AUTOCONNECT__ROUTER_HOSTNAME = "127.0.0.1"; }; wantedBy = ["multi-user.target"]; unitConfig.ConditionUser = "autopush"; serviceConfig = { EnvironmentFile = config.sops.secrets."autopush/autoconnect".path; ExecStart = "${autopush}/bin/autoconnect"; }; }; autopush-autoendpoint = { environment = { AUTOEND__DB_DSN = "redis://127.0.0.1:${redisPort}"; AUTOEND__HOST = "0.0.0.0"; AUTOEND__PORT = port; AUTOEND__ENDPOINT_URL = "https://update.${domain}"; }; wantedBy = ["multi-user.target"]; unitConfig.ConditionUser = "autopush"; serviceConfig = { EnvironmentFile = config.sops.secrets."autopush/autoendpoint".path; ExecStart = "${autopush}/bin/autoendpoint"; }; }; }; }