flake/projects/invokeai/package.nix
matthewcroughan 339a78b0e2 invokeai: support WSL via wrapper, not extra outputs
This removes the need to have multiple output variations like
invokeai-wsl-amd and instead just uses a simple bash wrapper to discover
whether the program is being ran in the WSL
2023-02-25 22:19:40 +00:00

84 lines
1.7 KiB
Nix

{ aipython3
# dependencies
, streamlit
# misc
, lib
, src
}:
let
getVersion = lib.flip lib.pipe [
(src: builtins.readFile "${src}/setup.py")
(builtins.match ".+VERSION = '([^']+)'.+")
builtins.head
];
in
aipython3.buildPythonPackage {
pname = "InvokeAI";
version = getVersion src;
inherit src;
propagatedBuildInputs = with aipython3; [
numpy
albumentations
opencv4
pudb
imageio
imageio-ffmpeg
pytorch-lightning
protobuf
omegaconf
test-tube
((streamlit.overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ pythonRelaxDepsHook ];
pythonRelaxDeps = [ "protobuf" ];
})).override { protobuf3 = protobuf; })
einops
taming-transformers-rom1504
torch-fidelity
torchmetrics
transformers
kornia
k-diffusion
picklescan
diffusers
pypatchmatch
realesrgan
pillow
send2trash
flask
flask-socketio
flask-cors
dependency-injector
gfpgan
eventlet
clipseg
getpass-asterisk
];
nativeBuildInputs = [ aipython3.pythonRelaxDepsHook ];
pythonRemoveDeps = [ "clip" "pyreadline3" "flaskwebgui" ];
pythonRelaxDeps = [ "protobuf" ];
makeWrapperArgs = [
'' --run '
if [ -d "/usr/lib/wsl/lib" ]
then
echo "Running via WSL (Windows Subsystem for Linux), setting LD_LIBRARY_PATH=/usr/lib/wsl/lib"
set -x
export LD_LIBRARY_PATH="/usr/lib/wsl/lib"
set +x
fi
'
''
];
postFixup = ''
chmod +x $out/bin/*
wrapPythonPrograms
'';
doCheck = false;
meta = {
description = "Fancy Web UI for Stable Diffusion";
homepage = "https://invoke-ai.github.io/InvokeAI/";
mainProgram = "invoke.py";
};
}