{ config, ... }: {
  sops.secrets.protonvpn_username = {};
  sops.secrets.protonvpn_password = {};

  sops.templates."transmission.env" = {
    content = ''
OPENVPN_PROVIDER=PROTONVPN
OPENVPN_CONFIG=mx.protonvpn.udp
OPENVPN_USERNAME=${config.sops.placeholder.protonvpn_username}+pmp
OPENVPN_PASSWORD=${config.sops.placeholder.protonvpn_password}
LOCAL_NETWORK=100.64.0.0/10
WEBPROXY_ENABLED=true
WEBPROXY_PORT=8118
'';
  };
  
  virtualisation.oci-containers.containers = {
    torrenty = {
      image = "docker.io/haugene/transmission-openvpn";
      ports = [ 
        "9091:9091"
        "8118:8118"
      ];
      environmentFiles = [
        config.sops.templates."transmission.env".path
      ];
      volumes = [
        "/mnt/nas0/public/Torrents:/data"
        "/mnt/nas0/public/Movies:/Movies"
        "/mnt/nas0/public/Anime:/Anime"
        "/mnt/nas0/public/AnimeMovies:/AnimeMovies"
        "/mnt/nas0/public/Shows:/Shows"
        "config:/config"
      ];
      extraOptions = [
        "--privileged"
      ];
      autoStart = true;
    };
  };

  systemd.units.podman-torrenty.upheldBy = ["mnt-nas0.mount"];
  systemd.units.podman-torrenty.enable = true;
}
