versotile-org / verso

A web browser that plays old world blues to build new world hope
Apache License 2.0
4.55k stars 155 forks source link

Flake #155

Open haras-unicorn opened 1 month ago

haras-unicorn commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

Fair

wusyong commented 1 month ago

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:

I think we can revisit this again once https://github.com/nix-community/nixGL/issues/90 is resolved as you mentioned in https://github.com/versotile-org/verso/issues/157

Kreyren commented 1 month ago

I think we can revisit this again once https://github.com/nix-community/nixGL/issues/90 is resolved as you mentioned in https://github.com/versotile-org/verso/issues/157 -- @wusyong (https://github.com/versotile-org/verso/pull/155#issuecomment-2292780884)

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.