nix-community / nixGL

A wrapper tool for nix OpenGL application [maintainer=@guibou]
628 stars 76 forks source link

[feature request] `source $(nixGL shell)` support #156

Open samuela opened 5 months ago

samuela commented 5 months ago

It would be super handy to be able to "install" nixGL into a shell session such that I don't have to worry about wrapping each command in nixGL foo ....

Would maintainers be supportive of including such a feature?

jim3692 commented 5 months ago

You can alias nix-shell to nixGL nixVulkanIntel nix-shell

samuela commented 5 months ago

That's certainly an option, but what I'm ideally looking for is a solution to "install" nixGL in the currently running shell instead of spawning a new one.

jim3692 commented 2 weeks ago

That's certainly an option, but what I'm ideally looking for is a solution to "install" nixGL in the currently running shell instead of spawning a new one.

Lately Arch updated its gcc version and now that alias fails with these errors:

nix-shell: /nix/store/bn7pnigb0f8874m6riiw6dngsmdyic1g-gcc-13.3.0-lib/lib/libstdc++.so.6: version `CXXABI_1.3.15' not found (required by /usr/lib/libnixexpr.so)
nix-shell: /nix/store/bn7pnigb0f8874m6riiw6dngsmdyic1g-gcc-13.3.0-lib/lib/libstdc++.so.6: version `CXXABI_1.3.15' not found (required by /usr/lib/libnixmain.so)
nix-shell: /nix/store/bn7pnigb0f8874m6riiw6dngsmdyic1g-gcc-13.3.0-lib/lib/libstdc++.so.6: version `CXXABI_1.3.15' not found (required by /usr/lib/libnixstore.so)
nix-shell: /nix/store/bn7pnigb0f8874m6riiw6dngsmdyic1g-gcc-13.3.0-lib/lib/libstdc++.so.6: version `CXXABI_1.3.15' not found (required by /usr/lib/libnixutil.so)

So, I came up with a more "install" solution:

if [[ ! "$IN_NIX_SHELL" = "" ]] && [[ "$IN_NIXGL" = "" ]]; then
  export IN_NIXGL=1
  source <(
    diff <(env) <(nixGL nixVulkanIntel env) \
      | grep '>' | sed 's/^>/export/g'
  )
fi

It extracts the environment variables that nixGL and nixVulkanIntel set, and adds them to the current shell.