This commit is contained in:
Denis Manherz 2023-11-09 17:09:34 +01:00
parent e4bdc8a48e
commit f10cfcffb1
5 changed files with 255 additions and 0 deletions

View file

@ -1,5 +1,22 @@
{ {
"nodes": { "nodes": {
"a1111-src": {
"flake": false,
"locked": {
"lastModified": 1693456714,
"narHash": "sha256-V16VkOq0+wea4zbfeKBLAQBth022ZkpG8lh0p9u4txs=",
"owner": "automatic1111",
"repo": "stable-diffusion-webui",
"rev": "5ef669de080814067961f28357256e8fe27544f4",
"type": "github"
},
"original": {
"owner": "automatic1111",
"ref": "v1.6.0",
"repo": "stable-diffusion-webui",
"type": "github"
}
},
"flake-parts": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
@ -185,6 +202,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"a1111-src": "a1111-src",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"hercules-ci-effects": "hercules-ci-effects", "hercules-ci-effects": "hercules-ci-effects",
"invokeai-src": "invokeai-src", "invokeai-src": "invokeai-src",

View file

@ -10,6 +10,10 @@
nixpkgs = { nixpkgs = {
url = "github:NixOS/nixpkgs/nixos-unstable"; url = "github:NixOS/nixpkgs/nixos-unstable";
}; };
a1111-src = {
url = "github:automatic1111/stable-diffusion-webui/v1.6.0";
flake = false;
};
invokeai-src = { invokeai-src = {
url = "github:invoke-ai/InvokeAI/v3.3.0post3"; url = "github:invoke-ai/InvokeAI/v3.3.0post3";
flake = false; flake = false;
@ -51,6 +55,7 @@
hercules-ci-effects.flakeModule hercules-ci-effects.flakeModule
# ./modules/nixpkgs-config # ./modules/nixpkgs-config
./overlays ./overlays
./projects/automatic1111
./projects/invokeai ./projects/invokeai
./projects/textgen ./projects/textgen
./website ./website

View file

@ -0,0 +1,14 @@
{
"internal": [
[
"<|BEGIN-VISIBLE-CHAT|>",
"How can I help you today?"
]
],
"visible": [
[
"",
"How can I help you today?"
]
]
}

View file

@ -0,0 +1,112 @@
{ config, inputs, lib, withSystem, ... }:
let
l = lib // config.flake.lib;
inherit (config.flake) overlays;
in
{
perSystem = { config, pkgs, ... }: let
commonOverlays = [
overlays.python-fixPackages
(l.overlays.callManyPackages [
../../packages/mediapipe
../../packages/safetensors
../../packages/easing-functions
../../packages/dynamicprompts
../../packages/controlnet-aux
../../packages/fastapi
../../packages/fastapi-events
../../packages/fastapi-socketio
../../packages/starlette
../../packages/pytorch-lightning
../../packages/compel
../../packages/taming-transformers-rom1504
../../packages/albumentations
../../packages/qudida
../../packages/gfpgan
../../packages/basicsr
../../packages/facexlib
../../packages/realesrgan
../../packages/codeformer
../../packages/clipseg
../../packages/kornia
../../packages/picklescan
../../packages/diffusers
../../packages/pypatchmatch
../../packages/torch-fidelity
../../packages/resize-right
../../packages/torchdiffeq
../../packages/accelerate
../../packages/clip-anytorch
../../packages/clean-fid
../../packages/getpass-asterisk
../../packages/mediapipe
../../packages/python-engineio
])
(final: prev: lib.mapAttrs
(_: pkg: pkg.overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ final.pythonRelaxDepsHook ];
pythonRemoveDeps = [ "opencv-python-headless" "opencv-python" "tb-nightly" "clip" ];
}))
{
inherit (prev)
albumentations
qudida
gfpgan
basicsr
facexlib
realesrgan
clipseg
;
}
)
];
python3Variants = {
amd = l.overlays.applyOverlays pkgs.python3Packages (commonOverlays ++ [
overlays.python-torchRocm
]);
nvidia = l.overlays.applyOverlays pkgs.python3Packages (commonOverlays ++ [
overlays.python-torchCuda
]);
};
src = inputs.a1111-src;
mkAutomatic1111Variant = args: pkgs.callPackage ./package.nix ({ inherit src; } // args);
in {
packages = {
a1111-nvidia = mkAutomatic1111Variant {
python3Packages = python3Variants.nvidia;
};
};
legacyPackages = {
a1111-amd = throw ''
BREEEE AMD?!
'';
};
};
flake.nixosModules = let
packageModule = pkgAttrName: { pkgs, ... }: {
services.a1111.package = withSystem pkgs.system (
{ config, ... }: lib.mkOptionDefault config.packages.${pkgAttrName}
);
};
in {
a1111 = ./nixos;
a1111-amd = {
imports = [
config.flake.nixosModules.invokeai
(packageModule "a1111-amd")
];
};
invokeai-nvidia = {
imports = [
config.flake.nixosModules.invokeai
(packageModule "a1111-nvidia")
];
};
};
}

View file

@ -0,0 +1,106 @@
{ python3Packages
# misc
, lib
, src
# extra deps
}:
python3Packages.buildPythonPackage {
pname = "Automatic1111";
format = "pyproject";
version = "v1.6.0";
inherit src;
propagatedBuildInputs = with python3Packages; [
semver
mediapipe
numpy
torchsde
uvicorn
pyperclip
invisible-watermark
fastapi
fastapi-events
fastapi-socketio
timm
scikit-image
controlnet-aux
compel
python-dotenv
uvloop
watchfiles
httptools
websockets
dnspython
albumentations
opencv4
pudb
imageio
imageio-ffmpeg
compel
npyscreen
pytorch-lightning
protobuf
omegaconf
test-tube
einops
taming-transformers-rom1504
torch-fidelity
torchmetrics
transformers
kornia
k-diffusion
picklescan
diffusers
pypatchmatch
realesrgan
pillow
send2trash
flask
flask-cors
dependency-injector
gfpgan
eventlet
clipseg
getpass-asterisk
safetensors
datasets
accelerate
huggingface-hub
easing-functions
dynamicprompts
torchvision
test-tube
];
nativeBuildInputs = with python3Packages; [ pythonRelaxDepsHook pip ];
pythonRemoveDeps = [ "clip" "pyreadline3" "flaskwebgui" "opencv-python" "fastapi-socketio" ];
pythonRelaxDeps = [ "dnspython" "flask" "requests" "numpy" "pytorch-lightning" "torchsde" "uvicorn" "invisible-watermark" "accelerate" "scikit-image" "safetensors" "huggingface-hub" "torchvision" "test-tube" "fastapi" ];
makeWrapperArgs = [
'' --run 'ls .'
''
# See note about consumer GPUs:
# https://docs.amd.com/bundle/ROCm-Deep-Learning-Guide-v5.4.3/page/Troubleshooting.html
" --set-default HSA_OVERRIDE_GFX_VERSION 10.3.0"
'' --run 'export INVOKEAI_ROOT="''${INVOKEAI_ROOT:-$HOME/.invokeai}"' ''
'' --run '
if [[ ! -d "$INVOKEAI_ROOT" && "''${0##*/}" != invokeai-configure ]]
then
echo "State directory does not exist, running invokeai-configure"
if [[ "''${NIXIFIED_AI_NONINTERACTIVE:-0}" != 0 ]]; then
${placeholder "out"}/bin/invokeai-configure --yes --skip-sd-weights
else
${placeholder "out"}/bin/invokeai-configure
fi
fi
'
''
];
patchPhase = ''
#runHook prePatch
echo here
'';
meta = {
description = "Fancy Web UI for Stable Diffusion";
homepage = "https://github.com/AUTOMATIC1111/stable-diffusion-webui";
mainProgram = "stable-diffusion-webui";
};
}