nix-community / nixGL

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

`nix-shell` example? #145

Open CyberShadow opened 9 months ago

CyberShadow commented 9 months ago

Hi, thanks for creating this.

Could you please add an example with nix-shell?

For example, if I'm running an application with nix-shell like this:

NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/7b1777b1e47d730dea558a5cd9b381cdee7b4f14.tar.gz nix-shell -p element-desktop --run element-desktop

How do I modify the above command to run element-desktop via nixGL?

Is a one-liner possible? Or do I have to create a .nix file for every occasion?

Thank you.

CyberShadow commented 1 month ago

I figured it out:

export NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/7b1777b1e47d730dea558a5cd9b381cdee7b4f14.tar.gz

$(nix-build https://github.com/nix-community/nixGL/archive/master.tar.gz -A nixGLIntel)/bin/nixGLIntel \
    nix-shell -p element-desktop --run element-desktop

To sum it up:

  1. Prefix the command with the output of `$(nix-build URL-to-this-repo-tarball -A nixGLTheFlavorYouWant)/bin/nixGLTheFlavorYouWant
  2. Make sure that nixGL and your application are targeting the same nixpkgs version, otherwise you may get glib version mismatches.