{ pkgs, config, lib, system, ... }: { config = let dir = "/var/lib/cytube"; yamlConfig = pkgs.writeText "config.yaml" (lib.generators.toYAML {} { mysql = { server = "localhost"; port = 3306; database = "cytube"; user = "cytube"; password = ""; pool-size = 10; }; listen = [ { ip = ""; port = 8080; http = true; } { ip = ""; port = 8081; io = true; url = "https://tube.tzlil.net"; } ]; http = { default-port = 8080; root-domain = "tube.tzlil.net"; alt-domains = []; minify = false; max-age = "7d"; gzip = true; gzip-threshold = 1024; cookie-secret = "tube.tzlil.net"; index = { max-entries = 50; }; trust-proxies = ["loopback"]; }; https = { enabled = false; }; html-template = { title = "TZLINC"; description = "lol"; }; io = { domain = "https://tube.tzlil.net"; default-port = 8081; }; youtube-v3-key = ""; max-channels-per-user = 1; max-accounts-per-ip = 5; ffmpeg = { enabled = true; ffprobe-exec = "ffprobe"; }; service-socket = { enabled = false; }; }); in { services.mysql = { enable = true; package = pkgs.mariadb; ensureDatabases = ["cytube"]; ensureUsers = [ { name = "cytube"; ensurePermissions = { "cytube.*" = "ALL PRIVILEGES"; }; } ]; settings = { mysqld = { bind-address = "127.0.0.1"; port = "3306"; }; }; }; virtualisation.oci-containers.containers.cytube = { ports = [ "8080:8080" "8081:8081" ]; image = "cytube"; imageFile = pkgs.dockerTools.buildImage { name = "cytube"; tag = "latest"; fromImage = pkgs.dockerTools.pullImage { imageName = "kittysh/cytube"; imageDigest = "sha256:77e6051c0fe4ce486375f53d80a5cb9a18e289db9cc8ba28e142287b53730455"; sha256 = "072gyx9s4nnq2i8h5b3n3vrcl5h7wigq9fzbf6y11n945km1ds2r"; finalImageName = "kittysh/cytube"; finalImageTag = "latest"; }; copyToRoot = pkgs.buildEnv { name = "image-root"; paths = [pkgs.ffmpeg]; pathsToLink = ["/bin"]; }; config.Cmd = ["node" "index.js"]; }; workdir = "/home/syncuser/sync"; extraOptions = ["--mount=type=bind,source=${yamlConfig},target=/home/syncuser/sync/config.yaml" "--network=host"]; }; environment.persistence."/nix/persist".directories = [ { directory = "${config.services.mysql.dataDir}"; user = "${config.services.mysql.user}"; group = "${config.services.mysql.group}"; } ]; services.caddy = { virtualHosts."tube.tzlil.net".extraConfig = '' bind 0.0.0.0 handle /socket.io/* { reverse_proxy :8081 } reverse_proxy :8080 ''; }; }; }