blender-mask-peoples/flake.nix
2026-02-12 18:26:22 +09:00

106 lines
3.9 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
description = "Blender VoiceVox Plugin Development Environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# Python環境
python311
python311Packages.pip
python311Packages.virtualenv
git
# C/C++標準ライブラリPyTorchなどに必要
stdenv.cc.cc.lib
zlib
zstd
# ROCm関連AMD GPU推論に必要
rocmPackages.clr
rocmPackages.rocm-smi
rocmPackages.rocm-runtime
];
shellHook = ''
python --version
blender --version | head -n 1
# ROCm
export ROCM_PATH="${pkgs.rocmPackages.clr}"
export HSA_OVERRIDE_GFX_VERSION="11.0.0" # RX 7900 (RDNA 3 / gfx1100)
# LD_LIBRARY_PATH: ROCmC++
export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.zlib}/lib:${pkgs.zstd.out}/lib:${pkgs.rocmPackages.clr}/lib:${pkgs.rocmPackages.rocm-runtime}/lib:$LD_LIBRARY_PATH"
# venv
VENV_DIR="$PWD/.venv"
if [ ! -d "$VENV_DIR" ]; then
echo "[Setup] Creating Python virtual environment..."
python -m venv "$VENV_DIR"
fi
# venv
source "$VENV_DIR/bin/activate"
#
if ! python -c "import torch; print(torch.cuda.is_available())" 2>/dev/null | grep -q "True"; then
echo "[Setup] Installing Python dependencies..."
# PyTorch ROCmROCm 7.0 nightly - ROCm 7.1.1
pip install --quiet --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm7.0
# PyPI
pip install --quiet \
ultralytics \
opencv-python-headless \
numpy \
fastapi \
uvicorn \
pydantic
# opencv-pythonheadless使
pip uninstall -y opencv-python opencv 2>/dev/null || true
# opencv-python-headless
pip install --quiet --force-reinstall opencv-python-headless
echo "[Setup] Dependencies installed successfully"
fi
# Python
export PYTHONPATH="$PWD:$PYTHONPATH"
#
export BLENDER_USER_SCRIPTS="$HOME/.config/blender/5.0/scripts"
export BLENDER_USER_ADDONS="$BLENDER_USER_SCRIPTS/addons"
#
cat > "$PWD/.env" << EOF
LD_LIBRARY_PATH=${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.zlib}/lib:${pkgs.zstd.out}/lib:${pkgs.rocmPackages.clr}/lib:${pkgs.rocmPackages.rocm-runtime}/lib
ROCM_PATH=${pkgs.rocmPackages.clr}
HSA_OVERRIDE_GFX_VERSION=11.0.0
PYTORCH_ROCM_ARCH=gfx1100
ROCBLAS_TENSILE_LIBPATH=${pkgs.rocmPackages.clr}/lib/rocblas/library
EOF
echo "[Setup] Environment ready with GPU support"
'';
};
}
);
}