Jump to content

Blender: Difference between revisions

From Official NixOS Wiki
Smudgebun (talk | contribs)
The cudaSupport Flag: Made section more concise, less repeated information between this and the CUDA page.
Smudgebun (talk | contribs)
m UI is dim on Vulkan backend and KDE Plasma: Updated known affected versions
 
(2 intermediate revisions by the same user not shown)
Line 143: 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>
Line 161: 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>
Line 177: 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 />

Latest revision as of 07:46, 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.

❄︎ shell.nix
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.

❄︎ configuration.nix
{
  services.blendfarm = {
    enable = true ;
    openFirewall = true;
    blenderPackage = pkgs.blender;
  };
}

Advanced Installation

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.

❄︎ flake.nix
{
  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;})

/* (blender.override {
    config.cudaSupport=true;
    config.rocmSupport=true;}) # to compile blender with both HIP and CUDA/OptiX support */
];

If installing Blender with cudaSupport, it is highly recommended you set up the CUDA Binary Cache. If you do not have it set up, and install Blender with cudaSupport, 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

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;
    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 */
];

oneAPI

Currently, Nixpkgs has extremely limited oneAPI support (see: 🚩︎[Tracking] OneAPI Packages), which is explicitly blocking 🚩︎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 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 on Blender's repo.

WAYLAND_DISPLAY=0 blender

References