Blender: Difference between revisions

Smudgebun (talk | contribs)
The cudaSupport Flag: Moved some non-Blender-specific information to the CUDA page, and added a link to that section. Clarified build information.
Smudgebun (talk | contribs)
m UI is dim on Vulkan backend and KDE Plasma: Updated known affected versions
 
(5 intermediate revisions by the same user not shown)
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 ==
Line 83: Line 143:
environment.systemPackages = with pkgs; [
environment.systemPackages = with pkgs; [
   (blender.override {config.cudaSupport=true;})
   (blender.override {config.cudaSupport=true;})
# (pkgsRocm.blender.override {config.cudaSupport=true;}) # to compile blender with both HIP and CUDA/OptiX support
 
/* (blender.override {
    config.cudaSupport=true;
    config.rocmSupport=true;}) # to compile blender with both HIP and CUDA/OptiX support */
];
];
</syntaxhighlight>
</syntaxhighlight>


NixOS Foundation does not cache CUDA versions of packages because of the unfree license. This means if you do not have the [[CUDA#Setting up CUDA Binary Cache|CUDA Binary Cache]] set up, your machine will be compiling Blender from source. Compiling Blender is very resource-intensive, so if you are unable to use the CUDA Cache, it is recommended to limit the number of cores or jobs that the process will take with the <code>--max-jobs</code> / <code>-j</code> and <code>--cores</code> flags whenever calling a command that will be building Blender, see: [https://github.com/NixOS/nix/blob/master/doc/manual/source/advanced-topics/cores-vs-jobs.md Tuning Cores & Jobs] for more information.
If installing Blender with <code>cudaSupport</code>, it is highly recommended you set up the [[CUDA#Setting up CUDA Binary Cache|CUDA Binary Cache]]. If you do not have it set up, and install Blender with <code>cudaSupport</code>, your machine will be compiling Blender from source.  
 
Compiling Blender is very resource-intensive, so if you are unable to use the CUDA Cache, please see the associated warning and information in [[CUDA#Enabling CUDA In Packages]].


==== Community Flakes ====
==== Community Flakes ====
Line 99: Line 164:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
environment.systemPackages = with pkgs; [
environment.systemPackages = with pkgs; [
   pkgsRocm.blender
   pkgsRocm.blender
# (blender.override {config.rocmSupport=true;}) # (equivalent to `pkgsRocm.blender`)
 
# (pkgsRocm.blender.override {config.cudaSupport=true;}) # to compile blender with both HIP and CUDA/OptiX support
/* (blender.override {
    config.rocmSupport=true;
    config.cudaSupport=false;}) # (equivalent to `pkgsRocm.blender`) */
 
/* (blender.override {
    config.cudaSupport=true;
    config.rocmSupport=true;}) # to compile blender with both HIP and CUDA/OptiX support */
];
];
</syntaxhighlight>
</syntaxhighlight>


=== oneAPI ===
=== oneAPI ===
Currently, Nixpkgs has extremely limited oneAPI support, (see: {{issue|367722|oneAPI Tracking}}), which is explicitly blocking oneAPI integration into the Blender package (see: {{issue|447245|Blender oneAPI Support}}). As such, the current only way to have oneAPI support on NixOS is through one of the [[#Binary Packages|#Binary Packages]]
Currently, Nixpkgs has extremely limited oneAPI support (see: {{issue|367722|<nowiki>[Tracking] OneAPI Packages</nowiki>}}), which is explicitly blocking {{issue|447245|Blender oneAPI Support}}. As such, the current only way to have oneAPI support on NixOS is through one of the [[#Binary Packages|#Binary Packages]].


=== Last Resorts ===
=== Last Resorts ===
Line 115: Line 187:
=== UI is dim on Vulkan backend and KDE Plasma ===
=== UI is dim on Vulkan backend and KDE Plasma ===


This is a cross-distro issue on current KDE Plasma (Wayland Session, KDE Version 6.6.3) and NVIDIA drivers (Versions 595.XX). A workaround option that doesn't require downgrading is to force XWayland by running Blender with the following command. See more information at the related {{issue|link=https://projects.blender.org/blender/blender/issues/155467||issue}} on Blender's repo.
This is a cross-distro issue on current KDE Plasma with NVIDIA, (confirmed issue on KDE Version 6.6.2-6.6.4 Wayland Session with NVIDIA drivers Versions 595.XX, though may affect others too). A workaround option that doesn't require downgrading is to force XWayland by running Blender with the following command. See more information at the related {{issue|link=https://projects.blender.org/blender/blender/issues/155467||issue}} on Blender's repo.
<syntaxhighlight lang="sh">
<syntaxhighlight lang="sh">
WAYLAND_DISPLAY=0 blender
WAYLAND_DISPLAY=0 blender
</syntaxhighlight>
</syntaxhighlight>


== References ==
== References ==
<references />
<references />