59 lines
1.6 KiB
Nix
59 lines
1.6 KiB
Nix
{ config, lib, ... }:
|
|
with lib;
|
|
let
|
|
common = config.selfhosted.common;
|
|
cfg = config.selfhosted.transmute;
|
|
hostDataPath = "${common.dataDir}/transmute";
|
|
in
|
|
{
|
|
imports = [ ./config.nix ];
|
|
|
|
options.selfhosted.transmute = {
|
|
enable = mkEnableOption "Enable ${cfg.name}";
|
|
name = mkOption {
|
|
type = types.str;
|
|
};
|
|
subdomain = mkOption {
|
|
type = types.str;
|
|
};
|
|
hostHttpPort = mkOption {
|
|
type = types.port;
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
virtualisation.oci-containers.containers."${cfg.name}" = {
|
|
image = "ghcr.io/transmute-app/transmute:v2.1.1";
|
|
ports = [
|
|
"0.0.0.0:${toString cfg.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}-${cfg.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}
|
|
'';
|
|
};
|
|
};
|
|
}
|