2024-07-10 07:50:31 +00:00
|
|
|
{ pkgs, lib, self }:
|
|
|
|
|
2024-07-27 12:22:22 +00:00
|
|
|
rec {
|
2024-07-10 07:50:31 +00:00
|
|
|
/* Given a Blender package and its addons to be wrapped, create a derivation
|
|
|
|
containing all of the addons properly placed as a system resource folder.
|
|
|
|
*/
|
|
|
|
wrapBlenderAddons = { blenderPackage, addons }:
|
2025-01-12 09:57:14 +00:00
|
|
|
let blenderVersion = lib.versions.majorMinor blenderPackage.version;
|
|
|
|
in pkgs.runCommand "blender-system-resources" {
|
|
|
|
passAsFile = [ "paths" ];
|
|
|
|
paths = addons ++ [ blenderPackage ];
|
|
|
|
nativeBuildInputs = with pkgs; [ outils ];
|
|
|
|
} ''
|
2024-07-10 07:50:31 +00:00
|
|
|
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
|
|
|
|
'';
|
2024-07-27 12:22:22 +00:00
|
|
|
|
2025-01-12 09:57:14 +00:00
|
|
|
makeBlenderWrapper =
|
|
|
|
module@{ blenderPackage, blenderArgs ? [ ], addons ? [ ], ... }:
|
|
|
|
let blenderAddons = wrapBlenderAddons { inherit blenderPackage addons; };
|
|
|
|
in lib.mkMerge [
|
2024-07-27 12:22:22 +00:00
|
|
|
{
|
|
|
|
arg0 = lib.getExe' blenderPackage "blender";
|
|
|
|
prependArgs = lib.mkBefore blenderArgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
(lib.mkIf (builtins.length addons > 0) {
|
2024-07-27 13:22:55 +00:00
|
|
|
env.BLENDER_SYSTEM_RESOURCES.value = blenderAddons;
|
2024-07-27 12:22:22 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
(lib.removeAttrs module [ "blenderPackage" "blenderArgs" "addons" ])
|
|
|
|
];
|
2024-07-31 05:37:22 +00:00
|
|
|
|
2025-01-12 09:57:14 +00:00
|
|
|
# Create a configuration module for quickly wrapping with Boxxy.
|
|
|
|
makeBoxxyWrapper =
|
|
|
|
module@{ boxxyArgs, wraparound, wraparoundArgs ? [ ], ... }:
|
2024-07-31 05:37:22 +00:00
|
|
|
lib.mkMerge [
|
|
|
|
{
|
|
|
|
arg0 = lib.getExe' pkgs.boxxy "boxxy";
|
2025-01-12 09:57:14 +00:00
|
|
|
prependArgs =
|
|
|
|
lib.mkBefore (boxxyArgs ++ [ "--" wraparound ] ++ wraparoundArgs);
|
2024-07-31 05:37:22 +00:00
|
|
|
}
|
|
|
|
|
2025-01-12 09:57:14 +00:00
|
|
|
(builtins.removeAttrs module [
|
|
|
|
"boxxyArgs"
|
|
|
|
"wraparound"
|
|
|
|
"wraparoundArgs"
|
|
|
|
])
|
2024-07-31 05:37:22 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
/* Given the path to the source code, the attribute path, and the executable
|
|
|
|
name, return the store path to one of its executables.
|
|
|
|
*/
|
2025-01-12 09:57:14 +00:00
|
|
|
getNixglExecutable =
|
|
|
|
{ src, variant ? [ "auto" "nixGLDefault" ], nixglProgram ? "nixGL" }:
|
2024-07-31 05:37:22 +00:00
|
|
|
let
|
|
|
|
nixgl = import src { inherit pkgs; };
|
|
|
|
nixglPkg = lib.getAttrFromPath variant nixgl;
|
2025-01-12 09:57:14 +00:00
|
|
|
in lib.getExe' nixglPkg nixglProgram;
|
2024-07-31 05:37:22 +00:00
|
|
|
|
2025-01-12 09:57:14 +00:00
|
|
|
# Create a configuration module for quickly wrapping with NixGL.
|
|
|
|
makeNixglWrapper = { nixglSrc, nixglArgs, nixglVariant, nixglExecutable
|
|
|
|
, wraparound, wraparoundArgs ? [ ], ... }@module:
|
2024-07-31 05:37:22 +00:00
|
|
|
lib.mkMerge [
|
|
|
|
{
|
|
|
|
arg0 = getNixglExecutable nixglSrc nixglVariant nixglExecutable;
|
2025-01-12 09:57:14 +00:00
|
|
|
prependArgs =
|
|
|
|
lib.mkBefore (nixglArgs ++ [ "--" wraparound ] ++ wraparoundArgs);
|
2024-07-31 05:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
(builtins.removeAttrs module [
|
2025-01-12 09:57:14 +00:00
|
|
|
"nixglArgs"
|
|
|
|
"nixglVariant"
|
|
|
|
"nixglExecutable"
|
|
|
|
"wraparound"
|
|
|
|
"wraparoundArgs"
|
2024-07-31 05:37:22 +00:00
|
|
|
])
|
|
|
|
];
|
2024-07-10 07:50:31 +00:00
|
|
|
}
|