diff --git a/lib/virtualisation.nix b/lib/virtualisation.nix index 9c40d2ac..776da2d2 100644 --- a/lib/virtualisation.nix +++ b/lib/virtualisation.nix @@ -12,6 +12,7 @@ vols ? [], env ? {}, opts ? [], + extraConfig ? {}, netns ? "", netdns ? "", }: let @@ -24,18 +25,19 @@ ++ (lib.optionals (netdns != "") [ "--dns=${netdns}" ]); - in { - image = image; - autoStart = autoStart; - ports = ports ++ expanded-id-ports; - volumes = vols; - environment = lib.mergeAttrs env { - PUID = "1000"; - PGID = "1000"; - TZ = "Europe/Berlin"; + in + lib.mergeAttrs extraConfig { + image = image; + autoStart = autoStart; + ports = ports ++ expanded-id-ports; + volumes = vols; + environment = lib.mergeAttrs env { + PUID = "1000"; + PGID = "1000"; + TZ = "Europe/Berlin"; + }; + extraOptions = opts ++ additional-opts; }; - extraOptions = opts ++ additional-opts; - }; # Filter all system service attributes that the user units don't have and add some required attributes # Example: podman-stablediffusion = mkOciUserService config.systemd.services.podman-stablediffusion; diff --git a/system/modules/containers/default.nix b/system/modules/containers/default.nix index 0cc77af6..1febf206 100644 --- a/system/modules/containers/default.nix +++ b/system/modules/containers/default.nix @@ -25,6 +25,30 @@ in { ]; }); + # Development + # NOTE: PyTorch ROCM image is 36 GB large... + # NOTE: This requires to setup the PodmanROCM direcory beforehand, as described here: + # https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-AMD-GPUs#running-inside-docker + # NOTE: This requires to manually link the launch.sh, since this is a system module (can't use home.file) + stablediffusion = mkIf cfg.stablediffusion.enable (mkOciContainer { + image = "rocm/pytorch:rocm5.5_ubuntu20.04_py3.8_pytorch_1.13.1"; + vols = [ + "/home/christoph/NoSync/StableDiffusionWebUI:/webui-data" + ]; + opts = [ + "--network=host" + "--device=/dev/kfd" + "--device=/dev/dri" + "--group-add=video" + "--ipc=host" + "--cap-add=SYS_PTRACE" + "--security-opt=seccomp=unconfined" + ]; + extraConfig = { + entrypoint = "/webui-data/launch.sh"; + }; + }); + # Multimedia jellyfin = mkIf cfg.jellyfin.enable (mkOciContainer { image = "linuxserver/jellyfin:10.8.10"; diff --git a/system/modules/containers/options.nix b/system/modules/containers/options.nix index 087df1a8..2b70eac8 100644 --- a/system/modules/containers/options.nix +++ b/system/modules/containers/options.nix @@ -14,6 +14,9 @@ with mylib.modules; { homeassistant = { enable = mkEnableOpt "Enable HomeAssistant Container"; }; + stablediffusion = { + enable = mkEnableOpt "Enable StableDiffusion Container with Automatic1111 WebUI"; + }; jellyfin = { enable = mkEnableOpt "Enable Jellyfin Container"; }; diff --git a/system/nixinator/default.nix b/system/nixinator/default.nix index 6694ff5c..9f3ff41f 100644 --- a/system/nixinator/default.nix +++ b/system/nixinator/default.nix @@ -19,6 +19,7 @@ enable = true; homeassistant.enable = false; + stablediffusion.enable = true; jellyfin.enable = true; fileflows.enable = false; sonarr.enable = true;