Blender: Difference between revisions
→The cudaSupport Flag: Moved some non-Blender-specific information to the CUDA page, and added a link to that section. Clarified build information. |
Added a section on installing with additional python modules |
||
| Line 11: | Line 11: | ||
If you want to install Blender with support for compute APIs, see: [[#Advanced Installation]] | If you want to install Blender with support for compute APIs, see: [[#Advanced Installation]] | ||
== Configuration == | |||
=== Installing With Additional Python Packages === | |||
To install additional Python modules into Blender, use the <code>withPackages</code> attribute. | |||
Example using a normal Blender package: | |||
<syntaxhighlight lang="nix"> | |||
environment.systemPackages = with pkgs; [ | |||
(blender.withPackages(ps: [ ps.pyserial ps.fs ]) | |||
]; | |||
</syntaxhighlight> | |||
Examples using abnormal Blender Packages: | |||
<syntaxhighlight lang="nix"> | |||
let | |||
blender-cuda = blender.override {config.cudaSupport=true;}; | |||
in { | |||
environment.systemPackages = with pkgs; [ | |||
(blender-cuda.withPackages(ps: [ ps.yq ]) | |||
# (pkgsRocm.blender.withPackages(ps: [ ps.pyserial ps.fs ]) | |||
]; | |||
} | |||
</syntaxhighlight> | |||
In these functions, <code>ps</code> is an alias for <code>python313Packages</code>. | |||
Installing with additional packages will result in a binary named <code>blender-wrapped</code> as it adds the python modules by wrapping Blender in a custom Python environment. When using a binary or unofficial Blender nix package, support for this feature will vary depending on if and how the packager implemented it. | |||
A workaround if using a package that doesn't support <code>withPackages</code> is to install the python packages globally. | |||
<syntaxhighlight lang="nix"> | |||
environment.systemPackages = with pkgs; [ | |||
python313Packages.yq | |||
python313Packages.pyserial | |||
]; | |||
</syntaxhighlight> | |||
Or if it fits your use case better, you can install them in a nix-shell and run Blender from within that shell. | |||
{{file|shell.nix|nix| | |||
<nowiki> | |||
let | |||
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-25.11"; | |||
pkgs = import nixpkgs { config = {}; overlays = []; }; | |||
in | |||
pkgs.mkShellNoCC { | |||
packages = with pkgs; [ | |||
python313Packages.yq | |||
python313Packages.fs | |||
# Optionally you can declare the Blender package you want to use in the shell, so you can run the shell in --pure. | |||
# Can be useful if you're trying to make a reproducible development shell or similar. | |||
pkgsRocm.blender | |||
]; | |||
} | |||
</nowiki> | |||
}} | |||
== Tips & Tricks == | == Tips & Tricks == | ||