nix-community / nixGL

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

Providing nixGL command via flake #90

Open jacg opened 2 years ago

jacg commented 2 years ago

Halcyon Days of Old

Many moons ago I used

nixGL = pkgs.callPackage "${builtins.fetchTarball {
    url = https://github.com/guibou/nixGL/archive/7d6bc1b21316bab6cf4a6520c2639a11c25a220e.tar.gz;
    #sha256 = pkgs.lib.fakeSha256;
    sha256 = "02y38zmdplk7a9ihsxvnrzhhv7324mmf5g8hmxqizaid5k5ydpr3";
}}/nixGL.nix" {};

and buildInputs = [ nixGL.nixGLDefault ];

to provide the nixGL command which automatically picked the correct implementation for whatever hardware I happened to be running.

Harsh and Cruel Present

Now I'm trying to provide nixGL in a flake, roughly like this

  inputs = { nixgl.url = "github:guibou/nixGL"; };

  ...

     overlays = [ nixgl.overlay ];

  ...

   devShell = pkgs.mkShell {
     buildInputs = [
       pkgs.nixgl.nixGLIntel         # Works
       pkgs.nixgl.nixGLDefault       # error: attribute 'nixGLDefault' missing 
       pkgs.nixgl.auto.nixGLDefault  # error: attribute 'currentTime' missing at /nix/store/8gs76jqmi2s8gqv68bakyyk3dx4a83db-source/nixGL.nix:202:18: 
     ];
   };

and I get the errors shown in the comments.

How should I go about providing nixGL in a devShell?

SuperSandro2000 commented 2 years ago

It should be pkgs.nixgl.auto.nixGLDefault.

jacg commented 2 years ago

It should be pkgs.nixgl.auto.nixGLDefault.

pkgs.nixgl.auto.nixGLDefault # copy-paste from MY message
pkgs.nixgl.auto.nixGLDefault # copy-paste from YOUR reply 

If there is a difference between what you wrote and what I wrote, then I can't spot it.

Copy-pasting your version into my local Nix expression gives exactly the same error as before.

j0xaf commented 2 years ago

Same issue here.

SuperSandro2000 commented 2 years ago

Did you pass --impure?

jacg commented 2 years ago

I was using the devShell via direnv and use flake.

Is there a way to get it to work with direnv?

SuperSandro2000 commented 2 years ago

You would need to tell devShell to be impure. Not sure how to do that.

j0xaf commented 2 years ago

So I ended up simply using nixGLIntel directly to stay pure.

scvalex commented 2 years ago

You would need to tell devShell to be impure. Not sure how to do that.

You can tell direnv to use the flake impurely. Just put this in your .envrc: use flake --impure.

scvalex commented 2 years ago

Although, once you do have an impure flake in your direnv, I don't know how to get it to re-evaluate when flake.nix is changed. Using nixGLIntel definitely works without the impure.

guibou commented 2 years ago

Thank you for the ticket and for the discussion.

Could we consider this as closed?

Perhaps we can improve the documentation to state that we need to use --impure for Nvidia drivers?

jacg commented 2 years ago

Sorry, it's been a while since I've thought about this, and I don't have time right now to go over it and refresh my memory and check details. With that said, a quick read suggests that it seems reasonable to consider this closed.

wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf commented 2 years ago

hey there, relatively new user here, thank you for the awesome project! it did (and continues to) save my bacon with flaky gui frameworks that I happen to be using.

I have been following this thread for a little while as I had a similar issue/requirement - I wanted to provide the nixGL (not nixGLIntel or any of the specific ones) command in my flake for easier collaboration (and since there is no way to do that as of now - without using --impure, apparently - , I just left notes in my flake pointing to this thread). the reason I wanted nixGL was to be able to use it on any GPU platform, relying on its auto-detection capabilities without the need to explicitly specify the right command for the right platform (I feel that is kind of the point of nixGLDefault).

Perhaps we can improve the documentation to state that we need to use --impure for Nvidia drivers?

in my opinion it would also help to note that using just nixGL (via nixGLDefault) in a flake won't work without --impure (as it is now), just the same as the nvidia variant you mention.

right, just my 2c.

guibou commented 2 years ago

Thank you for the comment @wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf

The point of nixGLDefault is clearly to auto detect, however all of that is only possible in --impure mode and when ran locally.

I'll add details in the doc.

Kreyren commented 3 months ago

Just to clarify for https://github.com/versotile-org/verso/pull/155 -> Is there a way to have a flake-based nix shell that is pure and has a working GL on a non-NixOS systems with nix?