-
Notifications
You must be signed in to change notification settings - Fork 84
Create nix flake #463
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
base: main
Are you sure you want to change the base?
Create nix flake #463
Conversation
|
I don't know anything about nix, @eddyb ? |
|
not maintainer --but I think forcing everyone to pull in the android toolchain might be a bit of an ask no? |
| { | ||
| devShells = { | ||
| default = pkgs.callPackage ./shell.nix { inherit rustToolchain; }; | ||
| android = pkgs.callPackage ./android.nix { inherit rustToolchain; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alphastrata This means you need to run nix develop .#android to get a dev shell with android, otherwise it'll just use default. (Though it wouldn't allow you to run the examples locally, since it's missing the deps that shell.nix provides... Maybe we should treat android as a purely additive thing?)
It looks good to me, but I'm not super familiar with nix myself, so I'll get @eddyb review it as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I see. ty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure for what the android.nix was used for, I am assuming just to cross compile to android? If so, I think it's fine that it won't allow to run the examples per default as it was already like this before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can compile the example-runner-wgpu to Android. But it's not documented in the example readme, could only find our Android CI building it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What packages would be missing? I could just try add them to the android devshell
|
One thing I am not sure about yet is how the rust-overlay flake input can be automatically updated when upgrading to a newer toolchain without forcing someone to use nix. With these changes, every time the rust toolchain is being updated, it would be necessary to run "nix flake update rust-overlay" as well to make sure the new toolchain version is known to nix. |
| description = "rust-gpu"; | ||
|
|
||
| inputs = { | ||
| nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the proper solution is but I will note that this approach has failed in the past:
Rust-GPU/rust-gpu-shadertoys#43 (comment)
Keeping default.nix (as shell.nix, which I suppose is more appropriate), does make this less drastic, and I can explicitly avoid touching the flake path until it's usable for myself on NixOS etc.
But it's hard to tell what value of flakes really is outside of e.g. CI.
| @@ -0,0 +1 @@ | |||
| use flake | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this common practice? I've never used a repo that came with an .envrc, and always did it locally, e.g. by running this (with a check that makes it idempotent, just in case I accidentally run it twice in the same directory):
git check-ignore -q .envrc || \
echo /.envrc >> $(git rev-parse --git-path info/exclude) && echo use nix >> .envrc && direnv allow(split onto two lines for readability on GitHub, it's just a oneliner in my shell history)
I use fish so typing any of envrc/use nix/direnv allow, and pressing ⬆️, is enough to recall it, but it is a weird thing I came up with when starting to use direnv (having already been using .git/info/exclude here and there whenever I didn't want to modify .gitignore etc.).
I have created a nix flake, that will fetch the required rust toolchain using rust-overlay.
By doing this, the toolchain does not need to be installed into the user environment directly.
I also added an
.envrc, this will allow to directly drop into a devshell if eg. direnv is used.