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 == | ||
Revision as of 05:32, 11 April 2026
Installation
Blender is an open-source 3D suite for modelling, animation, VFX, and more.
The default blender nix package is compiled without support for any compute APIs (CUDA, OptiX, oneAPI, HIP), and can be installed with the following in your configuration.
environment.systemPackages = with pkgs; [
blender
];
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 withPackages attribute.
Example using a normal Blender package:
environment.systemPackages = with pkgs; [
(blender.withPackages(ps: [ ps.pyserial ps.fs ])
];
Examples using abnormal Blender Packages:
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 ])
];
}
In these functions, ps is an alias for python313Packages.
Installing with additional packages will result in a binary named blender-wrapped 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 withPackages is to install the python packages globally.
environment.systemPackages = with pkgs; [
python313Packages.yq
python313Packages.pyserial
];
Or if it fits your use case better, you can install them in a nix-shell and run Blender from within that shell.
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
];
}
Tips & Tricks
Blendfarm
The Blendfarm network renderer for Blender is handled by services.blendfarm. A very simple example configuration is shown below.
{
services.blendfarm = {
enable = true ;
openFirewall = true;
blenderPackage = pkgs.blender;
};
}
Advanced Installation
- #Binary Packages for Blender binary packages with support for all APIs
- #CUDA & OptiX for support for NVIDIA's CUDA & OptiX
- #HIP for support for AMD's HIP
- #oneAPI for support for Intel's oneAPI
- #Last Resorts if all other methods don't work for your situation
Binary Packages
These are alternative distribution methods that package the Blender binaries, meaning they have support for all APIs.
Steam
Installing Blender through Steam will run Linux native Blender in the Steam Runtime environment, and it will receive automatic updates through Steam. Note that if you make Steam run the Windows version (through Proton) by selecting "Force the use of a specific Steam Play compatibility tool" under Properties > Compatibility, the APIs will fail as they will not have the relevant Windows drivers.
The blender-bin Flake
The unofficial blender-bin flake, provided by edolstra, packages the binary release of Blender for NixOS, and hosts it on FlakeHub here. The following demonstrates how to add the flake to a flake-based configuration.
{
description = "blender-bin example";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
# the '*' specifies the newest release
blender-bin.url = "https://flakehub.com/f/edolstra/blender-bin/*";
};
outputs = { self, nixpkgs, blender-bin }: {
nixosConfigurations.hostname = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux"; # the flake does not currently build for aarch64-linux
specialArgs = { inherit self system; };
modules = [
({self, system, ...}: {
environment.systemPackages = with self.inputs.blender-bin.packages.${system}; [
# 'default' is the latest blender version, though you can also pull a specific version e.g. 'blender_4_3'
default
];
})
];
};
};
}
CUDA & OptiX
By default Nixpkgs builds software with CUDA (and therefore OptiX) support disabled, because of the unfree license. For Blender there are multiple ways around this, detailed below.
The cudaSupport Flag
Whether a compatible package is built with CUDA support is managed by the cudaSupport flag enabled.
The following example shows how to override specifically the Blender package for CUDA support, for general information on the topic see: Enabling CUDA In Packages.
environment.systemPackages = with pkgs; [
(blender.override {config.cudaSupport=true;})
# (pkgsRocm.blender.override {config.cudaSupport=true;}) # to compile blender with both HIP and CUDA/OptiX support
];
NixOS Foundation does not cache CUDA versions of packages because of the unfree license. This means if you do not have the 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 --max-jobs / -j and --cores flags whenever calling a command that will be building Blender, see: Tuning Cores & Jobs for more information.
Community Flakes
In addition to the #blender-bin flake, there is also blender-cuda-nixos, which compiles Blender with cudaSupport enabled and caches it on cachix so you don't need to build it yourself. For the most up-to-date instructions on adding it to your configuration, see its README.
HIP
With the deprecation of the blender-hip package,[1] the easiest way to add Blender with HIP support is now with the pkgsRocm.blender package. Other methods are to use the rocmSupport config variable, or to use a #Binary Package.
The below example is Blender-specific. For more general information on enabling ROCm/HIP in your configuration, see: AMD GPU#Enabling ROCm & HIP For Packages.
environment.systemPackages = with pkgs; [
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
];
oneAPI
Currently, Nixpkgs has extremely limited oneAPI support, (see: 🚩︎oneAPI Tracking), which is explicitly blocking oneAPI integration into the Blender package (see: 🚩︎Blender oneAPI Support). As such, the current only way to have oneAPI support on NixOS is through one of the #Binary Packages
Last Resorts
If nothing else works for your situation, you can also download the Blender binary from blender.org and run it in NixOS using a program like nix-ld or nix-alien, patch the binary manually (see: Packaging/Binaries), or try using a container like Distrobox (see: Distrobox: Using the GPU Inside the Container).
Troubleshooting
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 on Blender's repo.
WAYLAND_DISPLAY=0 blender