diff --git a/dns/domains/xuyh0120.win.nix b/dns/domains/xuyh0120.win.nix index eeb9476a..53711b68 100644 --- a/dns/domains/xuyh0120.win.nix +++ b/dns/domains/xuyh0120.win.nix @@ -143,6 +143,12 @@ let target = "hetzner-de"; ttl = "1h"; } + { + recordType = "CNAME"; + name = "stable-diffusion"; + target = "lt-home-vm.ltnet.xuyh0120.win."; + ttl = "1h"; + } { recordType = "CNAME"; name = "stats"; diff --git a/helpers/constants.nix b/helpers/constants.nix index c9bef9aa..d15533c4 100644 --- a/helpers/constants.nix +++ b/helpers/constants.nix @@ -169,8 +169,7 @@ rec { Pterodactyl.Redis = 13679; Pterodactyl.Wings = 13680; Vaultwarden = 13772; - GoAutoconfig.Start = 13780; - GoAutoconfig.Stop = 13789; + StableDiffusionWebUI = 13786; Plausible = 13800; Netbox = 13801; Attic = 13803; diff --git a/hosts/lt-home-vm/configuration.nix b/hosts/lt-home-vm/configuration.nix index ee7261db..e7523e0e 100644 --- a/hosts/lt-home-vm/configuration.nix +++ b/hosts/lt-home-vm/configuration.nix @@ -33,6 +33,7 @@ ../../nixos/optional-apps/pterodactyl-panel.nix ../../nixos/optional-apps/pterodactyl-wings.nix ../../nixos/optional-apps/sftp-server.nix + ../../nixos/optional-apps/stable-diffusion-webui.nix ../../nixos/optional-apps/syncthing.nix ../../nixos/optional-apps/tachidesk.nix ../../nixos/optional-apps/uni-api.nix diff --git a/nixos/optional-apps/stable-diffusion-webui.nix b/nixos/optional-apps/stable-diffusion-webui.nix new file mode 100644 index 00000000..dcbff72a --- /dev/null +++ b/nixos/optional-apps/stable-diffusion-webui.nix @@ -0,0 +1,51 @@ +{ + LT, + ... +}: +let + subfolders = [ + # Data folders + "inputs" + "textual_inversion_templates" + "embeddings" + "extensions" + "models" + "localizations" + "outputs" + # Cache across container runs + "venv" + "repositories" + ]; +in +{ + virtualisation.oci-containers.containers.stable-diffusion = { + extraOptions = [ + "--pull" + "always" + "--gpus" + "all" + ]; + image = "universonic/stable-diffusion-webui"; + ports = [ "127.0.0.1:${LT.portStr.StableDiffusionWebUI}:8080" ]; + volumes = builtins.map ( + f: "/var/lib/stable-diffusion/${f}:/app/stable-diffusion-webui/${f}" + ) subfolders; + }; + + # Container uses UID/GID 1000 + systemd.tmpfiles.rules = builtins.map ( + f: "d /var/lib/stable-diffusion/${f} 755 1000 1000" + ) subfolders; + + lantian.nginxVhosts = { + "stable-diffusion.xuyh0120.win" = { + locations."/" = { + proxyPass = "http://127.0.0.1:${LT.portStr.StableDiffusionWebUI}"; + proxyWebsockets = true; + }; + + sslCertificate = "xuyh0120.win_ecc"; + noIndex.enable = true; + }; + }; +}