Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Providing nixGL command via flake #90

Open
jacg opened this issue Feb 10, 2022 · 14 comments
Open

Providing nixGL command via flake #90

jacg opened this issue Feb 10, 2022 · 14 comments

Comments

@jacg
Copy link

jacg commented Feb 10, 2022

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
Copy link
Member

It should be pkgs.nixgl.auto.nixGLDefault.

@jacg
Copy link
Author

jacg commented Feb 15, 2022

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
Copy link

j0xaf commented Feb 15, 2022

Same issue here.

@SuperSandro2000
Copy link
Member

Did you pass --impure?

@jacg
Copy link
Author

jacg commented Feb 17, 2022

I was using the devShell via direnv and use flake.

  • nix develop fails with the same error.
  • nix develop --impure succeeds.

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

@SuperSandro2000
Copy link
Member

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

@j0xaf
Copy link

j0xaf commented Feb 18, 2022

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

@scvalex
Copy link

scvalex commented May 12, 2022

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
Copy link

scvalex commented May 12, 2022

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
Copy link
Collaborator

guibou commented Jun 9, 2022

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
Copy link
Author

jacg commented Jun 9, 2022

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

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
Copy link
Collaborator

guibou commented Jun 10, 2022

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
Copy link

Kreyren commented Aug 15, 2024

Just to clarify for versotile-org/verso#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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants