The sound distributed version control system

#552 Alternative nix build with naersk

Opened by Anderssorby on October 16, 2021 Reviewing
Anderssorby on October 16, 2021

I’m experimenting with building pijul with naersk and a custom rust setup.

Anderssorby added a change on October 16, 2021
Anderssorby added a change on October 16, 2021
Fix nix build and use naersk to build by HZVQFtjbhnRsZNcTqNkbgkDT47NMwiGoHjvCqCkuekqp,
Anderssorby added a change on October 16, 2021
Fix nix build and use naersk to build by HZVQFtjbhnRsZNcTqNkbgkDT47NMwiGoHjvCqCkuekqp,
Anderssorby added a change on October 18, 2021
Update nix flake layout by HZVQFtjbhnRsZNcTqNkbgkDT47NMwiGoHjvCqCkuekqp,
pmeunier on November 27, 2021

(edited) there was a bug in the Nest, now fixed.

pmeunier 2 days ago

Why is naersk better than buildRustCrate?

Anderssorby 2 days ago

The main reason is that it reads Cargo.lock and Cargo.toml directly and downloads dependencies directly. So you don’t need to generate a Cargo.nix and can always be compatible with cargo build. So it is zero config essentially. Naersk also has a lot of options to control how the build is done, but it could be improved too. Now this is probably not the best setup and it uses naersk via my repo at yatima-inc/nix-utils to load the rust compiler. I did this mostly to test.

pmeunier 2 days ago

This could indeed be an advantage, how does Naersk deal with features?

pmeunier added tag Reviewing yesterday at 04:34
Anderssorby yesterday at 06:37

I’ve recently become a maintainer of naersk The documentation is minimal, usually I read the source to figure things out. To deal with features you simply need to add an argument to buildRustPackage like

pijul-git = pijul.override { cargoBuildOptions = d: d ++ [ "--features git" ]; };

You can override any argument and setting really although this is not very well documented at this point.

Anderssorby closed this discussion yesterday at 06:37
Anderssorby yesterday at 06:37

Didn’t mean to close the discussion.

Anderssorby reopened this discussion yesterday at 06:37
pmeunier yesterday at 07:59

My question was how are features propagated? I don’t know how Naersk works, but I wrote the initial version of buildRustCrate in nixpkgs, and I like how features are dealt with using the Nix language itself.

Also, I’ve never managed to use Naersk to build and deploy things in production (this website, for example). I think an extra file to build with Naersk would be ok, but I’m not too favourable to replacing the current system with it.

Anderssorby added a change yesterday at 12:36
Update cargo and nix flake by HZVQFtjbhnRsZNcTqNkbgkDT47NMwiGoHjvCqCkuekqp, created yesterday at 12:34
Anderssorby yesterday at 12:56

Naersk just gives a simple interface to build crates with cargo. It provides functions to for example load dependencies and read from Cargo.toml. I guess it could be made into a separate file. Naersk works out of the box mostly, but I’m using my lib yatima-inc/nix-utils to load rust nightly. Naersk is nice for deploying things really. You can control which files are copied to the output directory. We use it for everything in Yatima Inc although we don’t have any active deployments.

pmeunier yesterday at 13:06

Your patch contains lots of unrelated changes, I believe you could reset before recording. Also, are these against the latest main?

Anderssorby yesterday at 14:09

I should probably fix that yeah. I’ve had some problems using pijul itself. They are against an older main.