From f46cec6e1167d7b9656ab7e60e507a3b01cf79b9 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Wed, 10 Jul 2024 15:52:28 +0800 Subject: [PATCH] wrapper-manager/programs/blender: init Prototyping custom wrapper-manager-fds modules, hoorah! --- modules/wrapper-manager/default.nix | 5 ++ modules/wrapper-manager/programs/blender.nix | 63 ++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 modules/wrapper-manager/default.nix create mode 100644 modules/wrapper-manager/programs/blender.nix diff --git a/modules/wrapper-manager/default.nix b/modules/wrapper-manager/default.nix new file mode 100644 index 00000000..6a7c6f8c --- /dev/null +++ b/modules/wrapper-manager/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./programs/blender.nix + ]; +} diff --git a/modules/wrapper-manager/programs/blender.nix b/modules/wrapper-manager/programs/blender.nix new file mode 100644 index 00000000..f457fd53 --- /dev/null +++ b/modules/wrapper-manager/programs/blender.nix @@ -0,0 +1,63 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.programs.blender; + + blenderVersion = lib.versions.majorMinor cfg.package.version; + addons = + pkgs.runCommand "blender-system-resources" + { + passAsFile = [ "paths" ]; + paths = cfg.addons ++ [ cfg.package ]; + nativeBuildInputs = with pkgs; [ outils ]; + } '' + mkdir -p $out + for i in $(cat $pathsPath); do + resourcesPath="$i/share/blender" + if [ -d $i/share/blender/${blenderVersion} ]; then + resourcesPath="$i/share/blender/${blenderVersion}"; + fi + lndir -silent $resourcesPath $out + done + ''; +in +{ + options.programs.blender = { + enable = lib.mkEnableOption "Blender, a 3D computer graphics tool"; + + package = lib.mkPackageOption pkgs "blender" { + example = '' + pkgs.blender-with-packages { + name = "sample-studio-wrapped"; + packages = with pkgs.python3Packages; [ pandas ]; + } + ''; + }; + + addons = lib.mkOption { + type = with lib.types; listOf package; + description = lib.mdDoc '' + List of packages providing Blender system resources at + {file}`/share/blender` or at {file}`/share/blender/$MAJORMINORVERSION`. + ''; + default = [ ]; + defaultText = "[]"; + example = lib.literalExpression '' + with pkgs; [ + blender-addons-machin3tools + blender-addons-glslTexture + ] + ''; + }; + }; + + config = lib.mkIf cfg.enable { + basePackages = [ cfg.package ]; + + # TODO: Should we replace the .desktop file for this? + wrappers.blender = { + arg0 = lib.getExe' cfg.package "blender"; + env.BLENDER_SYSTEM_RESOURCES = lib.mkIf (builtins.length cfg.addons > 0) addons; + }; + }; +}