diff --git a/home/common/programs/3d.nix b/home/common/programs/3d.nix index 905cb08..40cef95 100644 --- a/home/common/programs/3d.nix +++ b/home/common/programs/3d.nix @@ -1,20 +1,43 @@ { + config, + lib, pkgs, ... }: +let + cfg = config.custom.blender; +in { - home.packages = with pkgs; [ - blender - prusa-slicer - ]; + options.custom.blender = { + cuda = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + Build Blender with CUDA/OptiX so Cycles renders on the GPU instead of + the CPU. Only useful on an NVIDIA host; enabling it on arrakis (Intel) + would mean a long build for nothing. - fonts.fontconfig.enable = true; + No binary cache serves this — cuda-maintainers was measured to make no + difference — so flipping this on rebuilds Blender, OpenUSD, OpenSubdiv + and OpenImageDenoise from source. + ''; + }; + }; - xdg.desktopEntries.prusaslicer-url-handler = { - name = "PrusaSlicer Protocol Handler"; - exec = "prusa-slicer %u"; - type = "Application"; - noDisplay = true; - mimeType = [ "x-scheme-handler/prusaslicer" ]; + config = { + home.packages = [ + (if cfg.cuda then pkgs.blender.override { cudaSupport = true; } else pkgs.blender) + pkgs.prusa-slicer + ]; + + fonts.fontconfig.enable = true; + + xdg.desktopEntries.prusaslicer-url-handler = { + name = "PrusaSlicer Protocol Handler"; + exec = "prusa-slicer %u"; + type = "Application"; + noDisplay = true; + mimeType = [ "x-scheme-handler/prusaslicer" ]; + }; }; }