Skip to content

Commit 39d00e9

Browse files
committed
fixes after re-install test
1 parent 5554e3c commit 39d00e9

File tree

4 files changed

+166
-154
lines changed

4 files changed

+166
-154
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ If you get an error `"hipErrorNoBinaryForGpu: Unable to find code object for all
5858

5959
# Current versions
6060

61-
- InvokeAI 2.3.1.post2
61+
- InvokeAI 2.3.5.post2
6262
- stable-diffusion-webui 12.03.2023
6363

6464
# Meta

flake.nix

Lines changed: 160 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@
111111
pythonRelaxDeps = [ "protobuf" ];
112112
});
113113
scikit-image = pythonPackages.scikitimage;
114+
moto = pythonPackages.moto.overrideAttrs (old: {
115+
doCheck = false;
116+
dontUsePytestCheck = true;
117+
118+
});
114119
};
115120
overlay_webui = nixpkgs: pythonPackages:
116121
{
@@ -125,32 +130,38 @@
125130
};
126131
overlay_invoke = nixpkgs: pythonPackages:
127132
let
128-
ifNotMinVersion = pkg: ver: overlay: if (
129-
nixlib.versionOlder pkg.version ver
130-
) then pkg.overrideAttrs overlay else pkg;
131-
in {
133+
ifNotMinVersion = pkg: ver: overlay:
134+
if (
135+
nixlib.versionOlder pkg.version ver
136+
) then pkg.overrideAttrs overlay else pkg;
137+
in
138+
{
132139
huggingface-hub = ifNotMinVersion pythonPackages.huggingface-hub
133-
"0.13.2" (
134-
old: rec {
135-
version = "0.14.1";
136-
src = nixpkgs.fetchFromGitHub {
137-
owner = "huggingface";
138-
repo = "huggingface_hub";
139-
rev = "refs/tags/v${version}";
140-
hash = "sha256-+BtXi+O+Ef4p4b+8FJCrZFsxX22ZYOPXylexFtsldnA=";
141-
};
142-
propagatedBuildInputs = old.propagatedBuildInputs ++ [pythonPackages.fsspec];
143-
});
140+
"0.13.2"
141+
(
142+
old: rec {
143+
version = "0.14.1";
144+
src = nixpkgs.fetchFromGitHub {
145+
owner = "huggingface";
146+
repo = "huggingface_hub";
147+
rev = "refs/tags/v${version}";
148+
hash = "sha256-+BtXi+O+Ef4p4b+8FJCrZFsxX22ZYOPXylexFtsldnA=";
149+
};
150+
propagatedBuildInputs = old.propagatedBuildInputs ++ [ pythonPackages.fsspec ];
151+
}
152+
);
144153
transformers = ifNotMinVersion pythonPackages.transformers
145-
"4.26" (
146-
old: rec {
147-
version = "4.28.1";
148-
src = nixpkgs.fetchFromGitHub {
149-
inherit (old.src) owner repo;
150-
rev = "refs/tags/v${version}";
151-
hash = "sha256-FmiuWfoFZjZf1/GbE6PmSkeshWWh+6nDj2u2PMSeDk0=";
152-
};
153-
});
154+
"4.26"
155+
(
156+
old: rec {
157+
version = "4.28.1";
158+
src = nixpkgs.fetchFromGitHub {
159+
inherit (old.src) owner repo;
160+
rev = "refs/tags/v${version}";
161+
hash = "sha256-FmiuWfoFZjZf1/GbE6PmSkeshWWh+6nDj2u2PMSeDk0=";
162+
};
163+
}
164+
);
154165
};
155166
overlay_pynixify = self:
156167
let
@@ -243,49 +254,50 @@
243254
in
244255
let
245256
nixpkgs_ = { amd ? false, nvidia ? false, webui ? false }:
246-
import inputs.nixpkgs {
247-
inherit system;
248-
config.allowUnfree = nvidia; #CUDA is unfree.
249-
overlays = [
250-
(final: prev:
251-
let
252-
optional = nixlib.optionalAttrs;
253-
sl = (prev.streamlit.override ({ protobuf3 = prev.protobuf; }));
254-
makePythonHook = args: final.makeSetupHook ({ passthru.provides.setupHook = true; } // args);
255-
pythonRelaxDepsHook = prev.callPackage
256-
({ wheel }:
257-
#upstream hook doesn't work properly with non-standard wheel names
258-
#which means that some packages from pip silently fail to be overriden
259-
#https://github.com/NixOS/nixpkgs/issues/198342
260-
makePythonHook
261-
{
262-
name = "python-relax-deps-hook";
263-
propagatedBuildInputs = [ wheel ];
264-
substitutions = {
265-
pythonInterpreter = nixlib.getExe prev.python3Packages.python;
266-
};
267-
} ./python-relax-deps-hook.sh)
268-
{ wheel = prev.python3.pkgs.wheel; };
269-
in
270-
{
271-
inherit pythonRelaxDepsHook;
272-
streamlit = sl.overrideAttrs (old: {
273-
nativeBuildInputs = old.nativeBuildInputs ++ [ pythonRelaxDepsHook ];
274-
pythonRemoveDeps = [ "protobuf" ];
275-
});
276-
python3 = prev.python3.override {
277-
packageOverrides =
278-
python-self: python-super:
279-
(overlay_default prev python-super) //
280-
optional amd (overlay_amd prev python-super) //
281-
optional nvidia (overlay_nvidia prev python-super) //
282-
optional webui (overlay_webui prev python-super) //
283-
optional (!webui) (overlay_invoke prev python-super) //
284-
(overlay_pynixify python-self);
285-
};
286-
})
287-
];
288-
} // { inherit nvidia; };
257+
import inputs.nixpkgs
258+
{
259+
inherit system;
260+
config.allowUnfree = nvidia; #CUDA is unfree.
261+
overlays = [
262+
(final: prev:
263+
let
264+
optional = nixlib.optionalAttrs;
265+
sl = (prev.streamlit.override ({ protobuf3 = prev.protobuf; }));
266+
makePythonHook = args: final.makeSetupHook ({ passthru.provides.setupHook = true; } // args);
267+
pythonRelaxDepsHook = prev.callPackage
268+
({ wheel }:
269+
#upstream hook doesn't work properly with non-standard wheel names
270+
#which means that some packages from pip silently fail to be overriden
271+
#https://github.com/NixOS/nixpkgs/issues/198342
272+
makePythonHook
273+
{
274+
name = "python-relax-deps-hook";
275+
propagatedBuildInputs = [ wheel ];
276+
substitutions = {
277+
pythonInterpreter = nixlib.getExe prev.python3Packages.python;
278+
};
279+
} ./python-relax-deps-hook.sh)
280+
{ wheel = prev.python3.pkgs.wheel; };
281+
in
282+
{
283+
inherit pythonRelaxDepsHook;
284+
streamlit = sl.overrideAttrs (old: {
285+
nativeBuildInputs = old.nativeBuildInputs ++ [ pythonRelaxDepsHook ];
286+
pythonRemoveDeps = [ "protobuf" ];
287+
});
288+
python3 = prev.python3.override {
289+
packageOverrides =
290+
python-self: python-super:
291+
(overlay_default prev python-super) //
292+
optional amd (overlay_amd prev python-super) //
293+
optional nvidia (overlay_nvidia prev python-super) //
294+
optional webui (overlay_webui prev python-super) //
295+
optional (!webui) (overlay_invoke prev python-super) //
296+
(overlay_pynixify python-self);
297+
};
298+
})
299+
];
300+
} // { inherit nvidia; };
289301
in
290302
{
291303
packages.${system} =
@@ -303,96 +315,96 @@
303315
pythonRelaxDeps = [ "torch" "pytorch-lightning" "flask-socketio" "flask" "dnspython" "fastapi" ];
304316
pythonRemoveDeps = [ "opencv-python" "flaskwebgui" "pyreadline3" ];
305317
postPatch = ''
306-
# Add subprocess to the imports
307-
substituteInPlace ./ldm/invoke/config/invokeai_configure.py --replace \
308-
'import shutil' \
309-
'
310-
import shutil
311-
import subprocess
312-
'
313-
# shutil.copytree will inherit the permissions of files in the /nix/store
314-
# which are read only, so we subprocess.call cp instead and tell it not to
315-
# preserve the mode
316-
substituteInPlace ./ldm/invoke/config/invokeai_configure.py --replace \
317-
"shutil.copytree(configs_src, configs_dest, dirs_exist_ok=True)" \
318-
"subprocess.call(f'cp -r --no-preserve=mode {configs_src}/* {configs_dest}', shell=True)"
318+
# Add subprocess to the imports
319+
substituteInPlace ./ldm/invoke/config/invokeai_configure.py --replace \
320+
'import shutil' \
321+
'
322+
import shutil
323+
import subprocess
324+
'
325+
# shutil.copytree will inherit the permissions of files in the /nix/store
326+
# which are read only, so we subprocess.call cp instead and tell it not to
327+
# preserve the mode
328+
substituteInPlace ./ldm/invoke/config/invokeai_configure.py --replace \
329+
"shutil.copytree(configs_src, configs_dest, dirs_exist_ok=True)" \
330+
"subprocess.call(f'${nixpkgs.pkgs.coreutils}/bin/cp -r --no-preserve=mode {configs_src}/* {configs_dest}', shell=True)"
319331
'';
320332
};
321-
webuiF = nixpkgs:
322-
let
323-
submodel = pkg: nixpkgs.pkgs.python3.pkgs.${pkg} + "/lib/python3.10/site-packages";
324-
taming-transformers = submodel "taming-transformers-rom1504";
325-
k_diffusion = submodel "k-diffusion";
326-
codeformer = (submodel "codeformer") + "/codeformer";
327-
blip = (submodel "blip") + "/blip";
328-
in
329-
nixpkgs.python3.pkgs.buildPythonApplication {
330-
pname = "stable-diffusion-webui";
331-
version = "2023-03-12";
332-
src = webui-repo;
333-
format = "other";
334-
propagatedBuildInputs = requirementsFor { pkgs = nixpkgs; webui = true; nvidia = nixpkgs.nvidia; };
335-
nativeBuildInputs = [ nixpkgs.pkgs.makeWrapper ];
336-
meta.mainProgram = "flake-launch";
337-
buildPhase = ''
338-
runHook preBuild
339-
cp -r . $out
340-
chmod -R +w $out
341-
cd $out
333+
webuiF = nixpkgs:
334+
let
335+
submodel = pkg: nixpkgs.pkgs.python3.pkgs.${pkg} + "/lib/python3.10/site-packages";
336+
taming-transformers = submodel "taming-transformers-rom1504";
337+
k_diffusion = submodel "k-diffusion";
338+
codeformer = (submodel "codeformer") + "/codeformer";
339+
blip = (submodel "blip") + "/blip";
340+
in
341+
nixpkgs.python3.pkgs.buildPythonApplication {
342+
pname = "stable-diffusion-webui";
343+
version = "2023-03-12";
344+
src = webui-repo;
345+
format = "other";
346+
propagatedBuildInputs = requirementsFor { pkgs = nixpkgs; webui = true; nvidia = nixpkgs.nvidia; };
347+
nativeBuildInputs = [ nixpkgs.pkgs.makeWrapper ];
348+
meta.mainProgram = "flake-launch";
349+
buildPhase = ''
350+
runHook preBuild
351+
cp -r . $out
352+
chmod -R +w $out
353+
cd $out
342354
343-
#firstly, we need to make launch.py runnable by adding python shebang
344-
cat <<-EOF > exec_launch.py.unwrapped
345-
$(echo "#!/usr/bin/python")
346-
$(cat launch.py)
347-
EOF
348-
chmod +x exec_launch.py.unwrapped
355+
#firstly, we need to make launch.py runnable by adding python shebang
356+
cat <<-EOF > exec_launch.py.unwrapped
357+
$(echo "#!/usr/bin/python")
358+
$(cat launch.py)
359+
EOF
360+
chmod +x exec_launch.py.unwrapped
349361
350-
#creating wrapper around launch.py with PYTHONPATH correctly set
351-
makeWrapper "$(pwd)/exec_launch.py.unwrapped" exec_launch.py \
352-
--set-default PYTHONPATH $PYTHONPATH
362+
#creating wrapper around launch.py with PYTHONPATH correctly set
363+
makeWrapper "$(pwd)/exec_launch.py.unwrapped" exec_launch.py \
364+
--set-default PYTHONPATH $PYTHONPATH
353365
354-
mkdir $out/bin
355-
pushd $out/bin
356-
ln -s ../exec_launch.py launch.py
357-
buck='$' #escaping $ inside shell inside shell is tricky
358-
#next is an additional shell wrapper, which sets sensible default args for CLI
359-
#additional arguments will be passed further
360-
cat <<-EOF > flake-launch
361-
#!/usr/bin/env bash
362-
pushd $out #For some reason, fastapi only works when current workdir is set inside the repo
363-
trap "popd" EXIT
366+
mkdir $out/bin
367+
pushd $out/bin
368+
ln -s ../exec_launch.py launch.py
369+
buck='$' #escaping $ inside shell inside shell is tricky
370+
#next is an additional shell wrapper, which sets sensible default args for CLI
371+
#additional arguments will be passed further
372+
cat <<-EOF > flake-launch
373+
#!/usr/bin/env bash
374+
pushd $out #For some reason, fastapi only works when current workdir is set inside the repo
375+
trap "popd" EXIT
364376
365-
"$out/bin/launch.py" --skip-install "$buck{@}"
366-
EOF
367-
# below lie remnants of my attempt to make webui use similar paths as InvokeAI for models download
368-
# additions of such options in upstream is a welcome sign, however they're mostly ignored and therefore useless
369-
# TODO: check in 6 months, maybe it'll work
370-
# For now, your best bet is to use ZFS dataset with dedup enabled or make symlinks after the fact
377+
"$out/bin/launch.py" --skip-install "$buck{@}"
378+
EOF
379+
# below lie remnants of my attempt to make webui use similar paths as InvokeAI for models download
380+
# additions of such options in upstream is a welcome sign, however they're mostly ignored and therefore useless
381+
# TODO: check in 6 months, maybe it'll work
382+
# For now, your best bet is to use ZFS dataset with dedup enabled or make symlinks after the fact
371383
372-
#--codeformer-models-path "\$mp/codeformer" \
373-
#--gfpgan-models-path "\$mp/gfpgan" --esrgan-models-path "\$mp/esrgan" \
374-
#--bsrgan-models-path "\$mp/bsrgan" --realesrgan-models-path "\$mp/realesrgan" \
375-
#--clip-models-path "\$mp/clip"
376-
chmod +x flake-launch
377-
popd
384+
#--codeformer-models-path "\$mp/codeformer" \
385+
#--gfpgan-models-path "\$mp/gfpgan" --esrgan-models-path "\$mp/esrgan" \
386+
#--bsrgan-models-path "\$mp/bsrgan" --realesrgan-models-path "\$mp/realesrgan" \
387+
#--clip-models-path "\$mp/clip"
388+
chmod +x flake-launch
389+
popd
378390
379-
runHook postBuild
380-
'';
381-
installPhase = ''
382-
runHook preInstall
391+
runHook postBuild
392+
'';
393+
installPhase = ''
394+
runHook preInstall
383395
384-
rm -rf repositories/
385-
mkdir repositories
386-
pushd repositories
387-
ln -s ${inputs.stable-diffusion-repo}/ stable-diffusion-stability-ai
388-
ln -s ${taming-transformers}/ taming-transformers
389-
ln -s ${k_diffusion}/ k-diffusion
390-
ln -s ${codeformer}/ CodeFormer
391-
ln -s ${blip}/ BLIP
392-
popd
393-
runHook postInstall
394-
'';
395-
};
396+
rm -rf repositories/
397+
mkdir repositories
398+
pushd repositories
399+
ln -s ${inputs.stable-diffusion-repo}/ stable-diffusion-stability-ai
400+
ln -s ${taming-transformers}/ taming-transformers
401+
ln -s ${k_diffusion}/ k-diffusion
402+
ln -s ${codeformer}/ CodeFormer
403+
ln -s ${blip}/ BLIP
404+
popd
405+
runHook postInstall
406+
'';
407+
};
396408
in
397409
{
398410
invokeai = {

packages/pypatchmatch/default.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
{ buildPythonPackage, lib, numpy, fetchFromGitHub, pillow, tqdm, setuptools, stdenv, pkg-config, opencv4 }:
1+
{ buildPythonPackage, lib, numpy, fetchFromGitHub, pillow, tqdm, setuptools, stdenv, pkg-config, opencv4 }:
22
let
33
version = "1.0.0";
44
src = fetchFromGitHub {
55
owner = "mauwii";
66
repo = "PyPatchMatch";
7-
rev = "release/v${version}";
8-
sha256 = "sha256-icxRmmxWvztQvMsYBJatvGa2YzxX05+xxdg+UJuy1SQ=";
7+
rev = "6eed571eaa57ae3047e2cafa202b56632198eb00";
8+
sha256 = "sha256-iE5anBvXku8gzWqlbIEI2PY1wj/i5Ww6stlXx6BaVpI=";
99
};
1010
libpatchmatch = stdenv.mkDerivation {
1111
name = "libpatchmatch";
12-
sourceRoot = ["source/patchmatch"];
12+
sourceRoot = [ "source/patchmatch" ];
1313
nativeBuildInputs = [
1414
pkg-config
1515
opencv4

packages/safetensors/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ buildPythonPackage rec {
2424
cargoDeps = rustPlatform.fetchCargoTarball {
2525
inherit src sourceRoot;
2626
name = sourceRoot;
27-
hash = "sha256-IsePAiBsA/YjO1rhae49+4q67WdN5ieBMmjpzxRxxNE=";
27+
hash = "sha256-3SluST4muwNxgt+GQ6ZuZ62TfMr5ZYiYN9M0QyhmsWc=";
2828
patches = [ ./cargo-lock.patch ];
2929
};
3030

0 commit comments

Comments
 (0)