{ config, lib, ... }: with lib; let rootCfg = config.selfhosted; common = rootCfg.common; moduleCfg = rootCfg.zerobyte; hostDataPath = "${common.dataDir}/zerobyte"; in { imports = [ ./config.nix ]; options.selfhosted.zerobyte = { enable = mkEnableOption "Enable ${moduleCfg.targetName}"; 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/nicotsx/zerobyte:v0.41"; environmentFiles = [ config.sops.templates."zerobyte.env".path ]; ports = [ "0.0.0.0:${toString moduleCfg.hostHttpPort}:4096" ]; volumes = [ "/etc/localtime:/etc/localtime:ro" "${hostDataPath}/data:/var/lib/zerobyte" "${hostDataPath}/backups:/mydata" ]; }; 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" ]; after = [ "${common.backend}-${common.rootTarget.name}.target" ]; preStart = '' mkdir -p ${hostDataPath}/{data,backups} ''; }; }; }