Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Flake#155

Draft
haras-unicorn wants to merge 1 commit intoversotile-org:mainfrom
haras-unicorn:flake
Draft

Flake#155
haras-unicorn wants to merge 1 commit intoversotile-org:mainfrom
haras-unicorn:flake

Conversation

@haras-unicorn
Copy link
Copy Markdown

I was going to add a package into nixpkgs for this but I realized the build step is a bit more complex than i liked so I went first to make this a flake and add a package via either cargo2nix or nixpkgs. This repo uses nix anyway and flakes are just a bit nicer way to setup a dev environment than just shell.nix IMO.

I am able to enter the shell but building with cargo gives me errors. It's rather long so I wont be posting that here.

I was not able to disable 32 bits for nixGL so I'd need a bit of help on that. I also replaced rustup with rustc and cargo since they're just faster to setup however that might lead to some issues.

@haras-unicorn haras-unicorn requested a review from wusyong as a code owner August 15, 2024 14:59
@haras-unicorn haras-unicorn marked this pull request as draft August 15, 2024 18:12
Copy link
Copy Markdown

@Kreyren Kreyren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on the cargo2nix? It seems like kinda standard nixpkgs package via buildRustPackage (https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md) to me?

Comment on lines +1 to +2
# NOTE: requires impure because of nixgl
use flake . --impure
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proposing to make a conditional check that uses impure on non-nixos setup and pure on nixos to keep the environment reproducible or some other management to avoid the impurity e.g. https://github.com/nix-community/nixGL?tab=readme-ov-file#install-nixgl which seems to install nixGL in the user profile, but i don't have much experience with it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nixgl cannot be used purely right now - see this discussion nix-community/nixGL#90
the link you posted also suggests to use --impure
i also want it to be pure but i found no way of doing this right now
for some reason unknown to me nixgl uses builtins.currentTime which cannot be used purely
if you know of a way to make it work purely id be happy to make a change

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a better solution atm. worst case if you are going to merge it with the --impure flag then i would suggest making an issue about it in verso for long-term tracking.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well FWIW one way that comes to mind rn, but feels a bit hacky is to declaratively make a shell application via writeShellApplication alike how i do tasks in nixium https://github.com/NiXium-org/NiXium/tree/central/tasks/administration/build as the way i understand it is that the script creation happens during nix's eval phase that then executes the created script with it's environment outside of nix's build envrionment to have the ability to use impure things, but i literally looked into nixgl yesterday and didn't have time to test if this is a good solution yet

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#157 added one rn so i dont forget

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sry im not smart enough to understand everything ur saying
id like to merge it impurely right now as its better than just a shell.nix imo but let someone smarter take care of the purity - or myself when i learn more about nix

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's okay everyone sucks at nix :D I try to look into it as i am researching nixGL myself rn and if i find a way i try to submit it here as well

@haras-unicorn
Copy link
Copy Markdown
Author

Can you elaborate on the cargo2nix? It seems like kinda standard nixpkgs package via buildRustPackage (https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md) to me?

I use it to speed up development in personal projects.
And yes that is the standard for nixpkgs, but I found it is easier to use cargo2nix.
The reason is that cargo2nix and other 2nix projects cache the compilation of dependencies in the nix store.
So for example, you want to check if nix is building your project correctly via nix build.
If you use nix build with a buildRustPackage package it will have to compile all the dependencies every single time you make a change because the compilation of all of your dependencies is just a byproduct of the compilation of your package.
If you use nix build with cargo2nix the first time it will compile everything. The second time you use nix build after making a change it just compiles your project like cargo build because it cached the result of compilation of all of your dependencies.

In summary, if I was adding verso to nixpkgs i would use buildRustPackage as that is the standard there. But here, for development purposes, I can use cargo2nix to cache compilation of dependencies and package this project in fewer lines of code.

@Kreyren
Copy link
Copy Markdown

Kreyren commented Aug 15, 2024

Fair

@wusyong
Copy link
Copy Markdown
Contributor

wusyong commented Aug 16, 2024

Hey, FYI, we probably will only support Flatpak for now.
Nix support serves only for development purposes. shell.nix is inspired by what Servo has.
There are still some dependency challenges in Nix that I think are worth mentioning if you want to push flake support:

  • Gstreamer
  • LLVM (which is stuck in v14)
  • X11/Wayland
  • GL driver and libraries

I think we can revisit this again once nix-community/nixGL#90 is resolved as you mentioned in #157

@Kreyren
Copy link
Copy Markdown

Kreyren commented Aug 16, 2024

I think we can revisit this again once nix-community/nixGL#90 is resolved as you mentioned in #157 -- @wusyong (#155 (comment))

That is not a blocking issue that would prevent functionality and only affects non-NixOS systems.. it's kinda a nice to have thing to make the shell more reproducible.

@wusyong wusyong mentioned this pull request Sep 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants