This commit is contained in:
Denis Manherz 2024-08-11 18:42:03 +02:00
parent f02dfd1b92
commit 1d9eaf10db
12 changed files with 780 additions and 164 deletions

136
+ Normal file
View file

@ -0,0 +1,136 @@
{
nixConfig = {
extra-substituters = ["https://ai.cachix.org"];
extra-trusted-public-keys = ["ai.cachix.org-1:N9dzRK+alWwoKXQlnn0H6aUx0lU/mspIoz8hMvGvbbc="];
};
description = "A Nix Flake that makes AI reproducible and easy to run";
inputs = {
comfyui-src = {
url = "github:comfyanonymous/ComfyUI";
flake = false;
};
nixpkgs-stable = {
url = "github:NixOS/nixpkgs/nixos-23.11";
};
bark-gui-src = {
url = "github:C0untFloyd/bark-gui";
flake = false;
};
kohya_ss-src = {
url = "github:bmaltais/kohya_ss";
flake = false;
};
sgm-src = {
url = "github:Stability-AI/generative-models";
flake = false;
};
nixpkgs = {
url = "github:NixOS/nixpkgs/nixos-unstable";
};
a1111-src = {
url = "github:automatic1111/stable-diffusion-webui";
flake = false;
};
sd-src = {
url = "github:Stability-AI/stablediffusion";
flake = false;
};
invokeai-src = {
url = "github:invoke-ai/InvokeAI/v3.6.2";
flake = false;
};
textgen-src = {
url = "github:oobabooga/text-generation-webui/v1.7";
flake = false;
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
hercules-ci-effects = {
url = "github:hercules-ci/hercules-ci-effects";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
flake-parts,
invokeai-src,
hercules-ci-effects,
...
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
perSystem = {system, ...}: let
asd = import inputs.nixpkgs-stable {
inherit system;
config = {
allowUnfree = true;
cudaSupport = true;
};
};
in {
# _module.args.pkgs = import inputs.nixpkgs { config.allowUnfree = true; inherit system; config.cudaSupport = true; };
_module.args.pkgs = import inputs.nixpkgs-stable {
inherit system;
config = {
allowUnfree = true;
cudaSupport = true;
allowBroken = true;
};
overlays = [
(
final: prev: {
pythonPackagesExtensions =
prev.pythonPackagesExtensions
++ [
(
python-final: python-prev: {
mediapipe = python-final.callPackage ./packages/mediapipe {};
basicsr = python-final.callPackage ./packages/basicsr {};
compel = python-final.callPackage ./packages/compel {};
controlnet-aux = python-final.callPackage ./packages/controlnet-aux {};
pypatchmatch = python-final.callPackage ./packages/pypatchmatch {};
facexlib = python-final.callPackage ./packages/facexlib {};
picklescan = python-final.callPackage ./packages/picklescan {};
opencv-python = python-final.opencv4;
dynamic-prompts = python-final.callPackage ./packages/dynamicprompts {};
easing-functions = python-final.callPackage ./packages/easing-functions {};
imohash = python-final.callPackage ./packages/imohash {};
diffusers = python-final.callPackage ./packages/diffusers {};
pydantic-settings = python-final.callPackage ./packages/pydantic-settings {};
}
)
];
}
)
];
};
legacyPackages = {
koboldai = builtins.throw ''
koboldai has been dropped from nixified.ai due to lack of upstream development,
try textgen instead which is better maintained. If you would like to use the last
available version of koboldai with nixified.ai, then run:
nix run github:nixified.ai/flake/0c58f8cba3fb42c54f2a7bf9bd45ee4cbc9f2477#koboldai
'';
};
};
systems = [
"x86_64-linux"
];
debug = true;
imports = [
hercules-ci-effects.flakeModule
# ./modules/nixpkgs-config
./overlays
./projects/comfyui
./projects/automatic1111
./projects/invokeai
./projects/textgen
./projects/kohya_ss
./projects/bark-gui
./website
];
};
}

View file

@ -3,11 +3,11 @@
"a1111-src": { "a1111-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1699030214, "lastModified": 1702709887,
"narHash": "sha256-UQ2cJ92JdSHOe0g5IkaCXPO0MYyWpLAcp6f8p+T6bxs=", "narHash": "sha256-xOId/D5eJszmRn0tCZtS+/u5WQUBpdPQ0I5XZIv3FvE=",
"owner": "automatic1111", "owner": "automatic1111",
"repo": "stable-diffusion-webui", "repo": "stable-diffusion-webui",
"rev": "4afaaf8a020c1df457bcf7250cb1c7f609699fa7", "rev": "cf2772fab0af5573da775e7437e6acdca424f26e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -35,11 +35,11 @@
"comfyui-src": { "comfyui-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1702736172, "lastModified": 1708708880,
"narHash": "sha256-BYZHfnhdubasOAhUyq/iW4HvYKPiqBwiXY3ozZXU1Oc=", "narHash": "sha256-0ibYcqMczdT9oN026EwxlnGeeBcKISJ+OToHp7cOUlY=",
"owner": "comfyanonymous", "owner": "comfyanonymous",
"repo": "ComfyUI", "repo": "ComfyUI",
"rev": "6453dc1ca2d98d89af7cf312bb48d1e3fd2ca27f", "rev": "1e5f0f66be93182f30d5d453dc8df50f3f7c1826",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -55,11 +55,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1685662779, "lastModified": 1706830856,
"narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=", "narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3", "rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -70,14 +70,17 @@
}, },
"flake-parts_2": { "flake-parts_2": {
"inputs": { "inputs": {
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": [
"hercules-ci-effects",
"nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1685662779, "lastModified": 1701473968,
"narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=", "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3", "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -85,77 +88,19 @@
"type": "indirect" "type": "indirect"
} }
}, },
"flake-parts_3": {
"inputs": {
"nixpkgs-lib": [
"hercules-ci-effects",
"hercules-ci-agent",
"nixpkgs"
]
},
"locked": {
"lastModified": 1685662779,
"narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"haskell-flake": {
"locked": {
"lastModified": 1684780604,
"narHash": "sha256-2uMZsewmRn7rRtAnnQNw1lj0uZBMh4m6Cs/7dV5YF08=",
"owner": "srid",
"repo": "haskell-flake",
"rev": "74210fa80a49f1b6f67223debdbf1494596ff9f2",
"type": "github"
},
"original": {
"owner": "srid",
"ref": "0.3.0",
"repo": "haskell-flake",
"type": "github"
}
},
"hercules-ci-agent": {
"inputs": {
"flake-parts": "flake-parts_3",
"haskell-flake": "haskell-flake",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1686721748,
"narHash": "sha256-ilD6ANYID+b0/+GTFbuZXfmu92bqVqY5ITKXSxqIp5A=",
"owner": "hercules-ci",
"repo": "hercules-ci-agent",
"rev": "7192b83935ab292a8e894db590dfd44f976e183b",
"type": "github"
},
"original": {
"id": "hercules-ci-agent",
"type": "indirect"
}
},
"hercules-ci-effects": { "hercules-ci-effects": {
"inputs": { "inputs": {
"flake-parts": "flake-parts_2", "flake-parts": "flake-parts_2",
"hercules-ci-agent": "hercules-ci-agent",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1686830987, "lastModified": 1708547820,
"narHash": "sha256-1XLTM0lFr3NV+0rd55SQW/8oQ3ACnqlYcda3FelIwHU=", "narHash": "sha256-xU/KC1PWqq5zL9dQ9wYhcdgxAwdeF/dJCLPH3PNZEBg=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "hercules-ci-effects", "repo": "hercules-ci-effects",
"rev": "04e4ab63b9eed2452edee1bb698827e1cb8265c6", "rev": "0ca27bd58e4d5be3135a4bef66b582e57abe8f4a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -184,11 +129,11 @@
"kohya_ss-src": { "kohya_ss-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1699706768, "lastModified": 1708789460,
"narHash": "sha256-/9YWOUbqErxrG5igF7CgUTGzxjSkOPhMA79wekGPfaQ=", "narHash": "sha256-ATc+1FH44B07az48AnQsp/dc1fv61/na4CI3NVHMhME=",
"owner": "bmaltais", "owner": "bmaltais",
"repo": "kohya_ss", "repo": "kohya_ss",
"rev": "9eb5da23002c6e00f084a19d62da6fc82074c773", "rev": "5d77bf409ff6a238aa2da94cf7910f97b8f1f1e9",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -199,11 +144,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1686501370, "lastModified": 1708655239,
"narHash": "sha256-G0WuM9fqTPRc2URKP9Lgi5nhZMqsfHGrdEbrLvAPJcg=", "narHash": "sha256-ZrP/yACUvDB+zbqYJsln4iwotbH6CTZiTkANJ0AgDv4=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "75a5ebf473cd60148ba9aec0d219f72e5cf52519", "rev": "cbc4211f0afffe6dfd2478a62615dd5175a13f9a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -213,24 +158,6 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1685564631,
"narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1708702655, "lastModified": 1708702655,
@ -247,22 +174,6 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1697059129,
"narHash": "sha256-9NJcFF9CEYPvHJ5ckE8kvINvI84SZZ87PvqMbH6pro0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5e4c2ada4fcd54b99d56d7bd62f384511a7e2593",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"a1111-src": "a1111-src", "a1111-src": "a1111-src",
@ -272,7 +183,7 @@
"hercules-ci-effects": "hercules-ci-effects", "hercules-ci-effects": "hercules-ci-effects",
"invokeai-src": "invokeai-src", "invokeai-src": "invokeai-src",
"kohya_ss-src": "kohya_ss-src", "kohya_ss-src": "kohya_ss-src",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs",
"nixpkgs-stable": "nixpkgs-stable", "nixpkgs-stable": "nixpkgs-stable",
"sd-src": "sd-src", "sd-src": "sd-src",
"sgm-src": "sgm-src", "sgm-src": "sgm-src",
@ -298,11 +209,11 @@
"sgm-src": { "sgm-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1692287310, "lastModified": 1708536887,
"narHash": "sha256-Gvpjfv5hFEeQl67OeTXVhiB4zvgV5UZ5B/ar4rBW0d0=", "narHash": "sha256-1jGByyT7EDHsCifLjlcvg9Y5BYb7cr3xR3+hsiQOaEA=",
"owner": "Stability-AI", "owner": "Stability-AI",
"repo": "generative-models", "repo": "generative-models",
"rev": "477d8b9a7730d9b2e92b326a770c0420d00308c9", "rev": "1e30a2df801a18c82a24223adfbdc71be0e8ca20",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -61,15 +61,55 @@
... ...
} @ inputs: } @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} { flake-parts.lib.mkFlake {inherit inputs;} {
perSystem = {system, ...}: { perSystem = {system, ...}: let
# _module.args.pkgs = import inputs.nixpkgs { config.allowUnfree = true; inherit system; config.cudaSupport = true; }; asd = import inputs.nixpkgs-stable {
_module.args.pkgs = import inputs.nixpkgs {
inherit system; inherit system;
config = { config = {
allowUnfree = true; allowUnfree = true;
cudaSupport = true; cudaSupport = true;
}; };
}; };
in {
# _module.args.pkgs = import inputs.nixpkgs { config.allowUnfree = true; inherit system; config.cudaSupport = true; };
_module.args.pkgs = import inputs.nixpkgs-stable {
inherit system;
config = {
allowUnfree = true;
cudaSupport = true;
allowBroken = true;
};
overlays = [
(
final: prev: {
pythonPackagesExtensions =
prev.pythonPackagesExtensions
++ [
(
python-final: python-prev: {
mediapipe = python-final.callPackage ./packages/mediapipe {};
basicsr = python-final.callPackage ./packages/basicsr {};
compel = python-final.callPackage ./packages/compel {};
controlnet-aux = python-final.callPackage ./packages/controlnet-aux {};
pypatchmatch = python-final.callPackage ./packages/pypatchmatch {};
facexlib = python-final.callPackage ./packages/facexlib {};
picklescan = python-final.callPackage ./packages/picklescan {};
opencv-python = python-final.opencv4;
dynamic-prompts = python-final.callPackage ./packages/dynamicprompts {};
easing-functions = python-final.callPackage ./packages/easing-functions {};
imohash = python-final.callPackage ./packages/imohash {};
diffusers = python-final.callPackage ./packages/diffusers {};
pydantic-settings = python-final.callPackage ./packages/pydantic-settings {};
pydantic = python-final.callPackage ./packages/pydantic {};
pillow-heif = python-prev.pillow-heif.overrideAttrs {
doCheck = false;
};
}
)
];
}
)
];
};
legacyPackages = { legacyPackages = {
koboldai = builtins.throw '' koboldai = builtins.throw ''
koboldai has been dropped from nixified.ai due to lack of upstream development, koboldai has been dropped from nixified.ai due to lack of upstream development,

View file

@ -1,18 +1,19 @@
{ lib {
, buildPythonPackage lib,
, fetchPypi buildPythonPackage,
, setuptools fetchPypi,
, wheel setuptools,
, filelock wheel,
, huggingface-hub filelock,
, opencv-python huggingface-hub,
, torchvision opencv4,
, einops torchvision,
, scikit-image einops,
, timm scikit-image,
, pythonRelaxDepsHook timm,
importlib-metadata,
pythonRelaxDepsHook,
}: }:
buildPythonPackage rec { buildPythonPackage rec {
pname = "controlnet-aux"; pname = "controlnet-aux";
version = "0.0.7"; version = "0.0.7";
@ -25,9 +26,10 @@ buildPythonPackage rec {
}; };
propagatedBuildInputs = [ propagatedBuildInputs = [
importlib-metadata
filelock filelock
huggingface-hub huggingface-hub
opencv-python opencv4
torchvision torchvision
einops einops
scikit-image scikit-image
@ -40,13 +42,13 @@ buildPythonPackage rec {
pythonRelaxDepsHook pythonRelaxDepsHook
]; ];
pythonImportsCheck = [ "controlnet_aux" ]; pythonImportsCheck = ["controlnet_aux"];
pythonRemoveDeps = [ "opencv-python" ]; pythonRemoveDeps = ["opencv-python"];
meta = with lib; { meta = with lib; {
description = "Auxillary models for controlnet"; description = "Auxillary models for controlnet";
homepage = "https://pypi.org/project/controlnet-aux/"; homepage = "https://pypi.org/project/controlnet-aux/";
license = licenses.asl20; license = licenses.asl20;
maintainers = with maintainers; [ ]; maintainers = with maintainers; [];
}; };
} }

View file

@ -1,10 +1,21 @@
# WARNING: This file was automatically generated. You should avoid editing it. # WARNING: This file was automatically generated. You should avoid editing it.
# If you run pynixify again, the file will be either overwritten or # If you run pynixify again, the file will be either overwritten or
# deleted, and you will lose the changes you made to it. # deleted, and you will lose the changes you made to it.
{
{ buildPythonPackage, cython, fetchPypi, filterpy, lib, numba, numpy buildPythonPackage,
, opencv-python, pillow, scipy, torch, torchvision, tqdm }: cython,
fetchPypi,
filterpy,
lib,
numba,
numpy,
opencv4,
pillow,
scipy,
torch,
torchvision,
tqdm,
}:
buildPythonPackage rec { buildPythonPackage rec {
pname = "facexlib"; pname = "facexlib";
version = "0.2.5"; version = "0.2.5";
@ -14,14 +25,14 @@ buildPythonPackage rec {
sha256 = "1r378mb167k2hynrn1wsi78xbh2aw6x68i8f70nmcqsxxp20rqii"; sha256 = "1r378mb167k2hynrn1wsi78xbh2aw6x68i8f70nmcqsxxp20rqii";
}; };
patches = [ ./root_dir.patch ]; patches = [./root_dir.patch];
buildInputs = [ cython numpy ]; buildInputs = [cython numpy];
propagatedBuildInputs = [ propagatedBuildInputs = [
filterpy filterpy
numba numba
numpy numpy
numpy numpy
opencv-python opencv4
pillow pillow
scipy scipy
torch torch

View file

@ -0,0 +1,30 @@
{
lib,
buildPythonPackage,
fetchPypi,
setuptools,
mmh3,
varint,
}:
buildPythonPackage rec {
pname = "imohash";
version = "1.0.5";
format = "pyproject";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-1d2HRoRk/grQjwrJUqVFAgUbkR+7wrkQZu3AUz4N9jc=";
};
propagatedBuildInputs = [mmh3 varint];
nativeBuildInputs = [setuptools];
doCheck = false;
meta = with lib; {
description = "imohash is a fast, constant-time hashing library. It uses file size and sampling to calculate hashes quickly, regardless of file size.";
homepage = "https://github.com/kalafut/py-imohash";
maintainers = with maintainers; [];
};
}

View file

@ -1,34 +1,37 @@
{ lib {
, fetchurl lib,
, buildPythonPackage fetchurl,
, protobuf buildPythonPackage,
, numpy protobuf,
, opencv4 numpy,
, attrs opencv4,
, matplotlib attrs,
, autoPatchelfHook matplotlib,
autoPatchelfHook,
sounddevice,
absl-py,
jax,
}: }:
buildPythonPackage { buildPythonPackage {
pname = "mediapipe"; pname = "mediapipe";
version = "0.10.7"; version = "0.10.7";
format = "wheel"; format = "wheel";
src = fetchurl { src = fetchurl {
url = "https://files.pythonhosted.org/packages/52/92/a2b0f9a943ebee88aa9dab040535ea05908ec102b8052b28c645cf0ac25b/mediapipe-0.10.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl"; url = "https://files.pythonhosted.org/packages/45/29/f4b59a010a62178308b40a7eef565a848b0cf12873bb46fba35b11d693bd/mediapipe-0.10.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl";
sha256 = "sha256-88kAkpxRn4Pj+Ib95WNj+53P36gHjpFt5rXlaX4bpco="; sha256 = "sha256-DMHivQf1CFLR5bakDs3Y0QTVEMHttEf4xxli11/RCXI=";
}; };
propagatedBuildInputs = [ protobuf numpy opencv4 matplotlib attrs ]; propagatedBuildInputs = [sounddevice absl-py jax protobuf numpy opencv4 matplotlib attrs];
nativeBuildInputs = [ autoPatchelfHook ]; nativeBuildInputs = [autoPatchelfHook];
pythonImportsCheck = [ "mediapipe" ]; pythonImportsCheck = ["mediapipe"];
meta = with lib; { meta = with lib; {
description = "Cross-platform, customizable ML solutions for live and streaming media"; description = "Cross-platform, customizable ML solutions for live and streaming media";
homepage = "https://github.com/google/mediapipe/releases/tag/v0.10.7"; homepage = "https://github.com/google/mediapipe/releases/tag/v0.10.7";
license = licenses.asl20; license = licenses.asl20;
maintainers = with maintainers; [ ]; maintainers = with maintainers; [];
}; };
} }

View file

@ -0,0 +1,267 @@
{
config,
stdenv,
lib,
fetchFromGitHub,
Foundation,
abseil-cpp,
cmake,
eigen,
gtest,
libpng,
nlohmann_json,
nsync,
pkg-config,
python3Packages,
re2,
zlib,
microsoft-gsl,
iconv,
protobuf_21,
pythonSupport ? true,
cudaSupport ? config.cudaSupport,
cudaPackages ? {},
} @ inputs: let
version = "1.16.3";
stdenv = throw "Use effectiveStdenv instead";
effectiveStdenv =
if cudaSupport
then cudaPackages.backendStdenv
else inputs.stdenv;
cudaCapabilities = cudaPackages.cudaFlags.cudaCapabilities;
# E.g. [ "80" "86" "90" ]
cudaArchitectures = builtins.map cudaPackages.cudaFlags.dropDot cudaCapabilities;
cudaArchitecturesString = lib.strings.concatStringsSep ";" cudaArchitectures;
howard-hinnant-date = fetchFromGitHub {
owner = "HowardHinnant";
repo = "date";
rev = "v2.4.1";
sha256 = "sha256-BYL7wxsYRI45l8C3VwxYIIocn5TzJnBtU0UZ9pHwwZw=";
};
mp11 = fetchFromGitHub {
owner = "boostorg";
repo = "mp11";
rev = "boost-1.79.0";
hash = "sha256-ZxgPDLvpISrjpEHKpLGBowRKGfSwTf6TBfJD18yw+LM=";
};
safeint = fetchFromGitHub {
owner = "dcleblanc";
repo = "safeint";
rev = "ff15c6ada150a5018c5ef2172401cb4529eac9c0";
hash = "sha256-PK1ce4C0uCR4TzLFg+elZdSk5DdPCRhhwT3LvEwWnPU=";
};
pytorch_cpuinfo = fetchFromGitHub {
owner = "pytorch";
repo = "cpuinfo";
# There are no tags in the repository
rev = "5916273f79a21551890fd3d56fc5375a78d1598d";
hash = "sha256-nXBnloVTuB+AVX59VDU/Wc+Dsx94o92YQuHp3jowx2A=";
};
flatbuffers = fetchFromGitHub {
owner = "google";
repo = "flatbuffers";
rev = "v1.12.0";
hash = "sha256-L1B5Y/c897Jg9fGwT2J3+vaXsZ+lfXnskp8Gto1p/Tg=";
};
onnx = fetchFromGitHub {
owner = "onnx";
repo = "onnx";
rev = "refs/tags/v1.14.1";
hash = "sha256-ZVSdk6LeAiZpQrrzLxphMbc1b3rNUMpcxcXPP8s/5tE=";
};
cutlass = fetchFromGitHub {
owner = "NVIDIA";
repo = "cutlass";
rev = "v3.0.0";
sha256 = "sha256-YPD5Sy6SvByjIcGtgeGH80TEKg2BtqJWSg46RvnJChY=";
};
in
effectiveStdenv.mkDerivation rec {
pname = "onnxruntime";
inherit version;
src = fetchFromGitHub {
owner = "microsoft";
repo = "onnxruntime";
rev = "refs/tags/v${version}";
hash = "sha256-bTW9Pc3rvH+c8VIlDDEtAXyA3sajVyY5Aqr6+SxaMF4=";
fetchSubmodules = true;
};
patches =
[
# If you stumble on these patches trying to update onnxruntime, check
# `git blame` and ping the introducers.
# Context: we want the upstream to
# - always try find_package first (FIND_PACKAGE_ARGS),
# - use MakeAvailable instead of the low-level Populate,
# - use Eigen3::Eigen as the target name (as declared by libeigen/eigen).
./0001-eigen-allow-dependency-injection.patch
]
++ lib.optionals cudaSupport [
# We apply the referenced 1064.patch ourselves to our nix dependency.
# FIND_PACKAGE_ARGS for CUDA was added in https://github.com/microsoft/onnxruntime/commit/87744e5 so it might be possible to delete this patch after upgrading to 1.17.0
./nvcc-gsl.patch
];
nativeBuildInputs =
[
cmake
pkg-config
python3Packages.python
protobuf_21
]
++ lib.optionals pythonSupport (with python3Packages; [
pip
python
pythonOutputDistHook
setuptools
wheel
])
++ lib.optionals cudaSupport [
cudaPackages.cuda_nvcc
];
buildInputs =
[
eigen
libpng
zlib
nlohmann_json
microsoft-gsl
]
++ lib.optionals pythonSupport (with python3Packages; [
gtest
numpy
pybind11
packaging
])
++ lib.optionals effectiveStdenv.isDarwin [
Foundation
iconv
]
++ lib.optionals cudaSupport (with cudaPackages; [
cuda_cccl # cub/cub.cuh
libcublas # cublas_v2.h
libcurand # curand.h
libcusparse # cusparse.h
libcufft # cufft.h
cudnn # cudnn.h
cuda_cudart
]);
nativeCheckInputs = lib.optionals pythonSupport (with python3Packages; [
pytest
sympy
onnx
]);
# TODO: build server, and move .so's to lib output
# Python's wheel is stored in a separate dist output
outputs = ["out" "dev"] ++ lib.optionals pythonSupport ["dist"];
enableParallelBuilding = true;
cmakeDir = "../cmake";
cmakeFlags =
[
"-DABSL_ENABLE_INSTALL=ON"
"-DFETCHCONTENT_FULLY_DISCONNECTED=ON"
"-DFETCHCONTENT_QUIET=OFF"
"-DFETCHCONTENT_SOURCE_DIR_ABSEIL_CPP=${abseil-cpp.src}"
"-DFETCHCONTENT_SOURCE_DIR_DATE=${howard-hinnant-date}"
"-DFETCHCONTENT_SOURCE_DIR_FLATBUFFERS=${flatbuffers}"
"-DFETCHCONTENT_SOURCE_DIR_GOOGLE_NSYNC=${nsync.src}"
"-DFETCHCONTENT_SOURCE_DIR_MP11=${mp11}"
"-DFETCHCONTENT_SOURCE_DIR_ONNX=${onnx}"
"-DFETCHCONTENT_SOURCE_DIR_PYTORCH_CPUINFO=${pytorch_cpuinfo}"
"-DFETCHCONTENT_SOURCE_DIR_RE2=${re2.src}"
"-DFETCHCONTENT_SOURCE_DIR_SAFEINT=${safeint}"
"-DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=ALWAYS"
"-Donnxruntime_BUILD_SHARED_LIB=ON"
"-Donnxruntime_BUILD_UNIT_TESTS=ON"
"-Donnxruntime_ENABLE_LTO=ON"
"-Donnxruntime_USE_FULL_PROTOBUF=OFF"
(lib.cmakeBool "onnxruntime_USE_CUDA" cudaSupport)
(lib.cmakeBool "onnxruntime_USE_NCCL" cudaSupport)
]
++ lib.optionals pythonSupport [
"-Donnxruntime_ENABLE_PYTHON=ON"
]
++ lib.optionals cudaSupport [
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_CUTLASS" cutlass)
(lib.cmakeFeature "onnxruntime_CUDNN_HOME" cudaPackages.cudnn)
(lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cudaArchitecturesString)
];
env = lib.optionalAttrs effectiveStdenv.cc.isClang {
NIX_CFLAGS_COMPILE = toString [
"-Wno-error=deprecated-declarations"
"-Wno-error=unused-but-set-variable"
];
};
doCheck = !cudaSupport;
requiredSystemFeatures = lib.optionals cudaSupport ["big-parallel"];
postPatch =
''
substituteInPlace cmake/libonnxruntime.pc.cmake.in \
--replace-fail '$'{prefix}/@CMAKE_INSTALL_ @CMAKE_INSTALL_
''
+ lib.optionalString (effectiveStdenv.hostPlatform.system == "aarch64-linux") ''
# https://github.com/NixOS/nixpkgs/pull/226734#issuecomment-1663028691
rm -v onnxruntime/test/optimizer/nhwc_transformer_test.cc
'';
postBuild = lib.optionalString pythonSupport ''
${python3Packages.python.interpreter} ../setup.py bdist_wheel
'';
postInstall = ''
# perform parts of `tools/ci_build/github/linux/copy_strip_binary.sh`
install -m644 -Dt $out/include \
../include/onnxruntime/core/framework/provider_options.h \
../include/onnxruntime/core/providers/cpu/cpu_provider_factory.h \
../include/onnxruntime/core/session/onnxruntime_*.h
'';
passthru = {
protobuf = protobuf_21;
tests = lib.optionalAttrs pythonSupport {
python = python3Packages.onnxruntime;
};
};
meta = with lib; {
description = "Cross-platform, high performance scoring engine for ML models";
longDescription = ''
ONNX Runtime is a performance-focused complete scoring engine
for Open Neural Network Exchange (ONNX) models, with an open
extensible architecture to continually address the latest developments
in AI and Deep Learning. ONNX Runtime stays up to date with the ONNX
standard with complete implementation of all ONNX operators, and
supports all ONNX releases (1.2+) with both future and backwards
compatibility.
'';
homepage = "https://github.com/microsoft/onnxruntime";
changelog = "https://github.com/microsoft/onnxruntime/releases/tag/v${version}";
# https://github.com/microsoft/onnxruntime/blob/master/BUILD.md#architectures
platforms = platforms.unix;
license = licenses.mit;
maintainers = with maintainers; [jonringer puffnfresh ck3d cbourjau];
};
}

View file

@ -0,0 +1,28 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,
hatchling,
}:
buildPythonPackage rec {
pname = "pydantic-settings";
version = "v2.1.0";
format = "pyproject";
src = fetchFromGitHub {
owner = "pydantic";
repo = pname;
rev = version;
sha256 = "sha256-hU7u/AzaqCHKSUDHybsgXTW8IWi9hzBttPYDmMqdZbI=";
};
propagatedBuildInputs = [hatchling];
doCheck = false;
meta = with lib; {
description = "Settings management using Pydantic, this is the new official home of Pydantic's BaseSettings.";
homepage = "https://github.com/pydantic/pydantic-settings";
maintainers = with maintainers; [];
};
}

View file

@ -0,0 +1,95 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,
pythonOlder,
# build-system
hatchling,
hatch-fancy-pypi-readme,
# native dependencies
libxcrypt,
# dependencies
annotated-types,
pydantic-core,
typing-extensions,
# tests
cloudpickle,
email-validator,
dirty-equals,
faker,
pytestCheckHook,
pytest-mock,
}:
buildPythonPackage rec {
pname = "pydantic";
version = "2.5.2";
pyproject = true;
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "pydantic";
repo = "pydantic";
rev = "refs/tags/v${version}";
hash = "sha256-D0gYcyrKVVDhBgV9sCVTkGq/kFmIoT9l0i5bRM1qxzM=";
};
doCheck = false;
buildInputs = lib.optionals (pythonOlder "3.9") [
libxcrypt
];
nativeBuildInputs = [
hatch-fancy-pypi-readme
hatchling
];
propagatedBuildInputs = [
annotated-types
pydantic-core
typing-extensions
];
passthru.optional-dependencies = {
email = [
email-validator
];
};
nativeCheckInputs =
[
cloudpickle
dirty-equals
faker
pytest-mock
pytestCheckHook
]
++ lib.flatten (lib.attrValues passthru.optional-dependencies);
preCheck = ''
export HOME=$(mktemp -d)
substituteInPlace pyproject.toml \
--replace "'--benchmark-columns', 'min,mean,stddev,outliers,rounds,iterations'," "" \
--replace "'--benchmark-group-by', 'group'," "" \
--replace "'--benchmark-warmup', 'on'," "" \
--replace "'--benchmark-disable'," ""
'';
disabledTestPaths = [
"tests/benchmarks"
# avoid cyclic dependency
"tests/test_docs.py"
];
pythonImportsCheck = ["pydantic"];
meta = with lib; {
description = "Data validation and settings management using Python type hinting";
homepage = "https://github.com/pydantic/pydantic";
changelog = "https://github.com/pydantic/pydantic/blob/v${version}/HISTORY.md";
license = licenses.mit;
maintainers = with maintainers; [wd15];
};
}

View file

@ -13,7 +13,7 @@
src = inputs.invokeai-src; src = inputs.invokeai-src;
in { in {
packages = { packages = {
invokeai-nvidia = pkgs.python311Packages.callPackage ./package.nix {inherit src;}; invokeai-nvidia = pkgs.python311Packages.callPackage ./package.nix {inherit pkgs src;};
}; };
}; };

View file

@ -1,7 +1,54 @@
{ {
pkgs,
imohash,
easing-functions,
dynamic-prompts,
accelerate,
picklescan,
facexlib,
pypatchmatch,
controlnet-aux,
compel,
basicsr,
onnx,
pytorch-lightning,
uvicorn,
torchmetrics,
timm,
transformers,
fastapi,
datasets,
python-socketio,
albumentations,
buildPythonPackage, buildPythonPackage,
setuptools,
starlette,
omegaconf,
pydantic,
#pypatchmatch,
test-tube,
pythonRelaxDepsHook,
pip,
lib, lib,
src, src,
semver,
rich,
npyscreen,
python-multipart,
matplotlib,
einops,
send2trash,
pympler,
prompt-toolkit,
pyperclip,
scikit-image,
dnspython,
pydantic-settings,
torchvision,
torchsde,
diffusers,
invisible-watermark,
mediapipe,
}: let }: let
getVersion = lib.flip lib.pipe [ getVersion = lib.flip lib.pipe [
(src: builtins.readFile "${src}/invokeai/version/invokeai_version.py") (src: builtins.readFile "${src}/invokeai/version/invokeai_version.py")
@ -15,9 +62,55 @@ in
version = getVersion src; version = getVersion src;
inherit src; inherit src;
propagatedBuildInputs = [ propagatedBuildInputs = [
pkgs.onnxruntime
imohash
dynamic-prompts
easing-functions
accelerate
mediapipe
diffusers
invisible-watermark
onnx
pytorch-lightning
timm
uvicorn
torchmetrics
torchvision
torchsde
pydantic-settings
albumentations
python-socketio
datasets
dnspython
pyperclip
scikit-image
einops
send2trash
pympler
prompt-toolkit
test-tube
setuptools
starlette
omegaconf
pydantic
semver
rich
npyscreen
python-multipart
matplotlib
#pypatchmatch
transformers
fastapi
picklescan
facexlib
pypatchmatch
controlnet-aux
compel
basicsr
]; ];
nativeBuildInputs = [pythonRelaxDepsHook pip];
pythonRemoveDeps = ["clip" "pyreadline3" "flaskwebgui" "opencv-python" "fastapi-socketio"]; 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"]; pythonRelaxDeps = ["dnspython" "flask" "torch" "requests" "numpy" "pytorch-lightning" "torchsde" "uvicorn" "invisible-watermark" "accelerate" "scikit-image" "safetensors" "huggingface-hub" "torchvision" "test-tube" "fastapi" "pydantic" "python-socketio" "transformers" "timm" "diffusers"];
makeWrapperArgs = [ makeWrapperArgs = [
'' --run ' '' --run '
if [ -d "/usr/lib/wsl/lib" ] if [ -d "/usr/lib/wsl/lib" ]