From f0bfe5e3fdc1fec6a9b41e2324a9f6c6207a2593 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Wed, 31 Jul 2024 13:37:22 +0800 Subject: [PATCH] lib/env-specific/wrapper-manager: add function for wrapping with Boxxy and NixGL --- lib/env-specific/wrapper-manager.nix | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/lib/env-specific/wrapper-manager.nix b/lib/env-specific/wrapper-manager.nix index 3de3d49c..c59e9996 100644 --- a/lib/env-specific/wrapper-manager.nix +++ b/lib/env-specific/wrapper-manager.nix @@ -40,4 +40,49 @@ rec { (lib.removeAttrs module [ "blenderPackage" "blenderArgs" "addons" ]) ]; + + /* Create a configuration module for quickly wrapping with Boxxy. + */ + makeBoxxyWrapper = module@{ boxxyArgs, wraparound, wraparoundArgs ? [], ... }: + lib.mkMerge [ + { + arg0 = lib.getExe' pkgs.boxxy "boxxy"; + prependArgs = lib.mkBefore (boxxyArgs ++ [ "--" wraparound ] ++ wraparoundArgs); + } + + (builtins.removeAttrs module [ "boxxyArgs" "wraparound" "wraparoundArgs" ]) + ]; + + /* Given the path to the source code, the attribute path, and the executable + name, return the store path to one of its executables. + */ + getNixglExecutable = { src, variant ? [ "auto" "nixGLDefault" ], nixglProgram ? "nixGL" }: + let + nixgl = import src { inherit pkgs; }; + nixglPkg = lib.getAttrFromPath variant nixgl; + in + lib.getExe' nixglPkg nixglProgram; + + /* Create a configuration module for quickly wrapping with NixGL. + */ + makeNixglWrapper = { + nixglSrc, + nixglArgs, + nixglVariant, + nixglExecutable, + wraparound, + wraparoundArgs ? [], + ... + }@module: + lib.mkMerge [ + { + arg0 = getNixglExecutable nixglSrc nixglVariant nixglExecutable; + prependArgs = lib.mkBefore (nixglArgs ++ [ "--" wraparound ] ++ wraparoundArgs); + } + + (builtins.removeAttrs module [ + "nixglArgs" "nixglVariant" "nixglExecutable" + "wraparound" "wraparoundArgs" + ]) + ]; }