From 8e93fe5dea0260ba7b494081c863df08ffb74ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Baylac=20Jacqu=C3=A9?= Date: Mon, 5 Dec 2022 15:04:09 +0100 Subject: [PATCH] DSO search: Add escape hatch We add a -d/--driver-directory flag allowing the user to circomvent the DSO automatic lookup and instead force nix-gl-host to load its dynamic libraries from a specific directory. --- src/nixglhost_wrapper.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/nixglhost_wrapper.py b/src/nixglhost_wrapper.py index 50bcab8..09b7006 100755 --- a/src/nixglhost_wrapper.py +++ b/src/nixglhost_wrapper.py @@ -419,9 +419,6 @@ def exec_binary(bin_path: str, args: List[str]) -> None: Sets the relevant libGLvnd env variables.""" log_info(f"Execv-ing {bin_path}") log_info(f"Goodbye now.") - # The following two env variables are required by our patched libglvnd - # implementation to figure out what kind of driver the host - # machine is using. os.execvp(bin_path, [bin_path] + args) @@ -432,7 +429,14 @@ def main(args): cache_dir = os.path.join(xdg_cache_home, "nix-gl-host") log_info(f'Using "{cache_dir}" as cache dir.') os.makedirs(cache_dir, exist_ok=True) - host_dsos_paths: List[str] = get_ld_paths() + if args.driver_directory: + log_info( + f"Retreiving DSOs from the specified directory: {args.driver_directory}" + ) + host_dsos_paths: List[str] = [args.driver_directory] + else: + log_info("Retrieving DSOs from the load path.") + host_dsos_paths: List[str] = get_ld_paths() new_env = nvidia_main(cache_dir, host_dsos_paths) os.environ.update(new_env) log_info(f"{time.time() - start_time} seconds elapsed since script start.") @@ -445,6 +449,13 @@ if __name__ == "__main__": prog="nixglhost-wrapper", description="Wrapper used to massage the host GL drivers to work with your nix-built binary.", ) + parser.add_argument( + "-d", + "--driver-directory", + type=str, + help="Use the driver libraries contained in this directory instead of discovering them from the load path.", + default=None, + ) parser.add_argument( "NIX_BINARY", type=str,