diff --git a/system/nixinator/default.nix b/system/nixinator/default.nix index 90c074d0..73f170e6 100644 --- a/system/nixinator/default.nix +++ b/system/nixinator/default.nix @@ -66,6 +66,7 @@ }; # TODO: System module for these + # TODO: I also want a function to generate these configs, I just want to pass volumes, ports, env and image virtualisation.oci-containers.containers = { jellyfin = { image = "linuxserver/jellyfin"; @@ -85,8 +86,36 @@ "/home/christoph/Videos/Concerts:/media/Concerts" # "/home/christoph/Music/Spotify:/media/Music:ro" ]; + + environment = { + PUID = "1000"; + PGID = "1000"; + TZ = "Europe/Berlin"; + }; }; + # TODO: When setting PUID/PGID fileflows can't access /temp dir + # fileflows = { + # image = "revenz/fileflows"; + # autoStart = false; + + # ports = [ + # "5000:5000" + # ]; + + # volumes = [ + # "fileflows-cache:/temp:Z" + # "fileflows-data:/app/Data:Z" + # "/home/christoph/Videos/Video:/media" + # ]; + + # environment = { + # PUID = "1000"; + # PGID = "1000"; + # TZ = "Europe/Berlin"; + # }; + # }; + sonarr = { image = "linuxserver/sonarr"; autoStart = false; @@ -105,6 +134,12 @@ "/home/christoph/Videos/Shows:/tv" "/home/christoph/Videos/SabNzbd:/downloads" ]; + + environment = { + PUID = "1000"; + PGID = "1000"; + TZ = "Europe/Berlin"; + }; }; radarr = { @@ -125,6 +160,12 @@ "/home/christoph/Videos/Movies:/movies" "/home/christoph/Videos/SabNzbd:/downloads" ]; + + environment = { + PUID = "1000"; + PGID = "1000"; + TZ = "Europe/Berlin"; + }; }; hydra = { @@ -144,6 +185,12 @@ "hydra-config:/config:Z" "/home/christoph/Videos/SabNzbd:/downloads" ]; + + environment = { + PUID = "1000"; + PGID = "1000"; + TZ = "Europe/Berlin"; + }; }; sabnzbd = { @@ -164,21 +211,33 @@ "/home/christoph/Videos/SabNzbd:/downloads" "/home/christoph/Videos/.sabnzbd:/incomplete-downloads" ]; + + environment = { + PUID = "1000"; + PGID = "1000"; + TZ = "Europe/Berlin"; + }; }; - picard = { - image = "mikenye/picard"; - autoStart = false; + # picard = { + # image = "mikenye/picard"; + # autoStart = false; - ports = [ - "5800:5800" - ]; + # ports = [ + # "5800:5800" + # ]; - volumes = [ - "picard-config:/config:Z" - "/home/christoph/Music/Spotify:/storage:rw,private" - ]; - }; + # volumes = [ + # "picard-config:/config:Z" + # "/home/christoph/Music/Spotify:/storage:rw,private" + # ]; + + # environment = { + # PUID = "1000"; + # PGID = "1000"; + # TZ = "Europe/Berlin"; + # }; + # }; homeassistant = { image = "homeassistant/home-assistant"; @@ -191,6 +250,12 @@ volumes = [ "homeassistant-config:/config:Z" ]; + + environment = { + PUID = "1000"; + PGID = "1000"; + TZ = "Europe/Berlin"; + }; }; # plex = { @@ -225,5 +290,121 @@ # "/home/christoph/Music/Spotify:/data/music:ro" # ]; # }; + + # TODO: Doesn't work, image is too large, no space left on device + # stablediffusion = let + # webui = pkgs.dockerTools.buildImage { + # name = "stablediffusion-webui"; + # # tag = "latest"; + + # # fromImage = "rocm/pytorch"; + # fromImage = pkgs.dockerTools.pullImage { + # imageName = "rocm/pytorch"; + # imageDigest = "sha256:994bc9eff6839143433caa6b665b7584dd623b03c65dc132f3827cf6480dcec1"; + # sha256 = ""; + # }; + # fromImageTag = "latest"; + + # runAsRoot = '' + # #!${pkgs.runtimeShell} + # cd /webui-data + # git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui + # cd stable-diffusion-webui + # python -m pip install --upgrade pip wheel + # ''; + + # config = { + # WorkingDir = "/webui-data/stable-diffusion-webui"; + # Env = { + # REQS_FILE = "/webui-data/stable-diffusion-webui/requirements.txt"; + # }; + # Cmd = [ + # "python" + # "launch.py" + # "--prevision" + # "full" + # "--no-half" + # ]; + # ExposedPorts = { + # "7860" = {}; + # }; + # }; + # }; + # in { + # image = "${webui}"; + # autoStart = false; + + # extraOptions = [ + # "--network=host" + # "--device=/dev/kfd" + # "--device=/dev/dri" + # "--group-add=video" + # "--ipc=host" + # "--cap-add=SYS_PTRACE" + # "--security-opt seccomp=unconfined" + # ]; + + # ports = [ + # "7860:7860" + # ]; + + # volumes = [ + # "/home/christoph/NoSync/PodmanROCM:/webui-data" + # ]; + + # environment = { + # PUID = "1000"; + # PGID = "1000"; + # TZ = "Europe/Berlin"; + # }; + # }; + + # 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 + stablediffusion = { + image = "rocm/pytorch"; + autoStart = false; + + extraOptions = [ + "--network=host" + "--device=/dev/kfd" + "--device=/dev/dri" + "--group-add=video" + "--ipc=host" + "--cap-add=SYS_PTRACE" + "--security-opt=seccomp=unconfined" + ]; + + volumes = [ + "/home/christoph/NoSync/StableDiffusionWebUI:/webui-data" + ]; + + # TODO: User christoph not found in passwd file + # user = "christoph:users"; + + environment = { + UID = "1000"; + GID = "100"; + TZ = "Europe/Berlin"; + }; + + entrypoint = "/webui-data/launch.sh"; + }; + }; + + # Make the system services available to the user + # NOTE: This doesn't work, since the cidfile is located in /run, which is not writable for regular users... + systemd.user.services = let + # Filter all system service attributes that the user units don't have and add some required attributes + system2user = attrs: lib.mergeAttrs (lib.attrsets.filterAttrs (n: v: !( + n == "confinement" || + n == "runner" || + n == "environment" + )) attrs) { + startLimitIntervalSec = 1; + startLimitBurst = 5; + }; + in { + # podman-stablediffusion = system2user config.systemd.services.podman-stablediffusion; }; }