{ config, lib, ... }: with lib; let rootCfg = config.selfhosted; common = rootCfg.common; moduleCfg = rootCfg.transmute; hostDataPath = "${common.dataDir}/transmute"; in { imports = [ ./config.nix ]; options.selfhosted.transmute = { enable = mkEnableOption "Enable ${moduleCfg.name}"; name = mkOption { type = types.str; }; subdomain = mkOption { type = types.str; }; hostHttpPort = mkOption { type = types.port; }; }; config = mkIf moduleCfg.enable { virtualisation.oci-containers.containers."${moduleCfg.name}" = { image = "ghcr.io/transmute-app/transmute:v2.1.1"; ports = [ "0.0.0.0:${toString moduleCfg.hostHttpPort}:3313" ]; environmentFiles = [ config.sops.templates."transmute.env".path ]; volumes = [ "${hostDataPath}/data:/app/data" ]; log-driver = "journald"; extraOptions = [ "--network=${common.network.name}" "--health-cmd=wget -q -O /dev/null --tries=1 http://localhost:3313/api/health/ready" "--health-interval=30s" "--health-timeout=10s" "--health-retries=3" "--health-start-period=40s" ]; }; systemd.services."${common.backend}-${moduleCfg.name}" = { serviceConfig = { Restart = lib.mkOverride 90 "always"; }; wantedBy = [ "${common.backend}-${common.rootTarget.name}.target" ]; partOf = [ "${common.backend}-${common.rootTarget.name}.target" ]; preStart = '' mkdir -p ${hostDataPath}/data chown -R ${common.user.uid}:${common.group.gid} ${hostDataPath} chmod -R 0775 ${hostDataPath} ''; }; }; }