Porting more Rust

There are some cool tools written in Rust that I’d like to port to Haiku (namely, jujutsu, typst, and nushell). What’s the best way to approach it?

I know that some things like ripgrep are already ported to Haiku. So I’d like to have a bit of guidance from people who already ported some Rust to Haiku.

You can try to use cargo to install them as usual and see what happens.

If you want to turn them into haikuports recipes, haikuporter comes with a tool to generate one from the cargo.toml file.

Some of the software or more likely some of the lowlevel dependencies may need some patching. There isn’t really a process for that, you have to work with the upstream developers and either wait until they merge the pach, or get your cargo.toml pointing at your version of the patched sources.

The currently available compiler might be too old for software using the very latest features.

I see, thanks.

Our rust toolchain isn’t actually in that bad of shape (surprisingly better than our go port)

Here’s some info:

Overall it runs well minus the occasional sys crate that needs patching

A small script I sometimes use to quickly check on rust sources for packages (I tend to do this quite often hence that small script is useful to me). :slight_smile:

#/bin/sh
cargo fetch
cargo build --release --frozen

cargo install --locked --root $prefix --path .

When things work out ok then I start writing a recipe for it, in any way, plenty of people around to help you out. Enjoy your journey! :slight_smile:

1 Like

@suhr:
For information, typst is already ported and available on Haiku Depot.

Notice, though, that for some reason I didn’t have time to investigate so far, the typst’s watch feature doesn’t works as expected on Haiku. Probably because the notify crate has no support for Haiku yet.

If you want to port some tools written in Rust, you can look into HaikuPorts github, searching for any *.recipe file with “cmd:cargo” in them (well, in BUILD_PREREQUIRES block - the others ones are in fact the recipes to build the Rust toolchain stuff itselt):

Files with cmd:cargo in haikuports github repository

The list is not that small, so multiple examples to learn from.

For a biased example I know quite well, the port of typst:
https://github.com/haikuports/haikuports/tree/master/app-text/typst

2 Likes

It looks like for some recent projects this isn’t true anymore and our rust version could use an update?

/Opslag/wip/jj-0.31.0> cargoScript 
error: failed to parse manifest at `/Opslag/wip/jj-0.31.0/Cargo.toml`

Caused by:
  feature `edition2024` is required

I’ve managed to compile some (just some!) Rust applications by opening Cargo.toml and changing 2024 to 2021. It looks like that setting is set by the toolchain automatically, without checking what the actual mininum requirements are.

1 Like

Great tip, “when” I run into it again I must check that out! (although I “try” to stay away from building rust packages/sources if I can) :slight_smile:

The reason the edition is set to the most recent for new projects is so that you don’t need to go learn how to write Rust as it was five or ten years ago, but can instead just write Rust today and it’ll work. If cargo new made you a project with edition 2015 then everything you learn about Rust today but which couldn’t have worked in that edition will just not work for you, and weirdly things that shouldn’t work (because they’re a bad idea) will seem to compile because in this old edition they were not forbidden. The priority was developers not an improved experience for people who want to build the software on unsupported operating systems.

1 Like

I will try to make Rust 1.89.0 available to make sure the 2024 edition is easily accesssible.

15 Likes

When the Rust compiler port on Haiku is updated, I’ll try to get MS Edit ported over as soon as possible. It needs feature flags, but can otherwise be made to compile in the latest Rust stable compiler.

@nielx updated rust_bin to 1.89.0 yesteday (big thanks there!!! :heart: ) :slight_smile:

8 Likes