gdnative-book icon indicating copy to clipboard operation
gdnative-book copied to clipboard

Updating shell.nix to flakes

Open jaoleal opened this issue 11 months ago • 11 comments

Updating the shell.nix to a flake.nix. See the Issue on gdnative for more understanding.

https://github.com/godot-rust/gdnative/pull/1069#issuecomment-1971001997

jaoleal avatar Feb 29 '24 12:02 jaoleal

Actually, im not a experienced user of NixOs, flakes and all that good stuff. I prefer that some other folks check the content too

jaoleal avatar Feb 29 '24 14:02 jaoleal

Im commting the nix on non-nixos changes. May the Nixgl is not necessary at all.

jaoleal avatar Feb 29 '24 20:02 jaoleal

Should the old content really be replaced altogether? On https://nixos.wiki/wiki/Flakes it is stated that (emphasis mine):

Nix flakes is an experimental feature of the Nix package manager.

Not everyone might want to enable experimental features for their package manager, and not everyone is using NixOS (instead of non-NixOS Nix environments, which the previous author apparently was on, and this setup is stated to not support). I'm not sure if the old directions should be removed, if it isn't superseded entirely.

chitoyuu avatar Mar 01 '24 17:03 chitoyuu

Nix flakes are pretty widely used nowadays despite that warning. Even then, I agree we should keep previous instructions regarding default.nix and shell.nix (& co.) if they were already there. I'd be more in favor of having a separate section, e.g. "Using Flakes", with an alternative setup with flakes. They do deserve a mention, but that doesn't mean we have to remove or deprecate prior instructions. (Disclaimer: I am a NixOS user, but I'm not a full expert on the subject.)

Of note, unless we are doing something with some specific cursed dependencies, it's very likely a Nix setup - with flakes or otherwise - would work on non-NixOS environments as well. At least, it's worth testing in other distros with Nix installed (e.g. Ubuntu, Fedora, OpenSUSE).

EDIT: From a quick look at the PR, it seems that NixGL is used, so I think there might be problems using this particular setup outside of NixOS, but I'm not sure. Worth testing.

PgBiel avatar Mar 01 '24 18:03 PgBiel

Even then, I agree we should keep previous instructions regarding default.nix and shell.nix (& co.) if they were already there. I'd be more in favor of having a separate section, e.g. "Using Flakes", with an alternative setup with flakes.

If you have a Flake.nix it is trivial to extend that to a Nix shell. The problem with Nix shells (outside of a Flake, i.e. default.nix or shell.nix) is that they are not reproducible and are tied to the users config and nixpkgs.

storopoli avatar Mar 01 '24 18:03 storopoli

If you have a Flake.nix it is trivial to extend that to a Nix shell.

True, you have a point. You can use flake-compat to convert a Flake to the older format. Then, for the sake of maintainability, it might be better to just present the flake setup, and suggest using flake-compat if flakes are not enabled.

Alternatively, we can have some more high-level instructions indicating which packages you need to use gdnative with Nix, and then use the flake as an example.

PgBiel avatar Mar 01 '24 18:03 PgBiel

@jaoleal see if you understand these suggestions. I think that they are a good way forward for this PR. I can help you clarify anything if you need.

storopoli avatar Mar 01 '24 18:03 storopoli

Should the old content really be replaced altogether?

Well, thinking that is good if we have options to use on Nix... I think that we have to maintain those that work and not hold on to outdated technologies or ways to do the same thing. In every context that i used that file, i had problems.

jaoleal avatar Mar 01 '24 18:03 jaoleal

Of note, unless we are doing something with some specific cursed dependencies, it's very likely a Nix setup - with flakes or otherwise - would work on non-NixOS environments as well. At least, it's worth testing in other distros with Nix installed (e.g. Ubuntu, Fedora, OpenSUSE).

So, the non-NixOs environment... In that context, as the previous docs say, we could have some problems with opengl and then we could use NixGl that... is something I couldn't get to work on my environment until now, i`ll give another try. If my speak sound confusing, feel free to ask me again.

jaoleal avatar Mar 01 '24 19:03 jaoleal

Of note, unless we are doing something with some specific cursed dependencies, it's very likely a Nix setup - with flakes or otherwise - would work on non-NixOS environments as well. At least, it's worth testing in other distros with Nix installed (e.g. Ubuntu, Fedora, OpenSUSE).

So, the non-NixOs environment... In that context, as the previous docs say, we could have some problems with opengl and then we could use NixGl that... is something I couldn't get to work on my environment until now, i`ll give another try. If my speak sound confusing, feel free to ask me again.

No you're right, I hadn't seen the NixGL dependency. That one can definitely be a pain outside of NixOS I believe. So it's fair enough.

I do, however, wonder if there's some escape hatch which would allow us to not depend on NixGL for non-NixOS users. But that will suffice for the goal of this PR.

PgBiel avatar Mar 01 '24 19:03 PgBiel

I do, however, wonder if there's some escape hatch which would allow us to not depend on NixGL for non-NixOS users. But that will suffice for the goal of this PR.

The goal of this PR is that anyone have to spend some time on managing painfull deps. ill be happy to ensure that non-NixOs nix users have they time saved but i cannot absolutely sure that it will work... i only have a NixOs machine. Anyway, ill try to include NixGl on the party. :)

jaoleal avatar Mar 01 '24 19:03 jaoleal