Skip to content
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

[Do not merge] Rust packaging #4568

Closed
wants to merge 3 commits into from
Closed

[Do not merge] Rust packaging #4568

wants to merge 3 commits into from

Conversation

madjar
Copy link
Member

@madjar madjar commented Oct 17, 2014

Hello there

I've been working on the packaging of rust program (those that use cargo, to be specific), and here is what I've got for now.

You can package arbitrary rust package using buildRustPackage. It takes 4 arguments: a name, a src (a fetchgit derivation for example), sha256 (the sha of the cargo dependencies), and a optional buildInputs.

You can look at the provided rust-example.nix to see what it looks like and try it out (it is a small game I wrote to try rust out).

A lot of things must be finished before merging:

  • The api buildRustPackage is not final at all. If you have comment on the right way to do it, or if you can me to good examples in nixpkgs, I'd be grateful.
  • The documentation.
  • The nix-prefetch-cargo should be on par with other nix-prefetch script, because it is required to determine the sha of the dependencies.
  • Cargo itself does not build (actually, I can get it to build on nixos, even outside of nixpkgs). I think I'll wait for RFC: Overhaul Cargo's build command support rust-lang/rfcs#403 to be implemented before trying again.

@wizeman

@madjar madjar added the 2.status: work-in-progress This PR isn't done label Oct 17, 2014
@madjar madjar self-assigned this Oct 17, 2014
@wizeman
Copy link
Member

wizeman commented Oct 21, 2014

Great work!

From what I can tell it is looking good to me, but I'm not familiar with prefetch scripts or custom builders so unfortunately I can't provide better feedback...

Am I deducing correctly that the current problem with building cargo itself with buildRustPackage is that cargo is downloading native code library dependencies outside of "cargo fetch"?

@madjar
Copy link
Member Author

madjar commented Oct 22, 2014

@wizeman Not at all. The problem with building cargo itself is that one of its native dependencies does not built because of a missing flag somewhere. If you want to investigate the problem, you can try to build cargo outside of nixpkgs, the same problem will appears.

@jagajaga
Copy link
Member

jagajaga commented Nov 3, 2014

rust-lang/rfcs#403 is closed. So what situation do we have now?

@madjar
Copy link
Member Author

madjar commented Nov 3, 2014

It's merged but not yet implemented.

I'll probably have time to look into it next week, and I'll try to ship something usable.

I'll also try a different approach that uses dependencies overrides instead of cargo fetch.

@jagajaga
Copy link
Member

jagajaga commented Nov 3, 2014

Nice. Maybe I can help you?

@madjar
Copy link
Member Author

madjar commented Nov 3, 2014

Sure! Independently of the nixpkgs part, the main problem is with compiling
cargo on NixOS. If you could try and see if you can get it to compile, that
would help a lot.
Le 3 nov. 2014 15:20, "Arseniy Seroka" [email protected] a écrit :

Nice. Maybe I can help you?


Reply to this email directly or view it on GitHub
#4568 (comment).

@michaeljones
Copy link

+1, I'm interested in Rust development with Nix. Happy to help/test if I can.

@jagajaga
Copy link
Member

I've added racer and a vim plugin for it (a tool to provide rust code completion).
ec8bfcb

@madjar
Copy link
Member Author

madjar commented Dec 4, 2014

Update: I've started working on a new approach, which makes package expressions nicer. The result can me seen there: https://github.com/madjar/nixpkgs/blob/rust/pkgs/development/tools/build-managers/cargo/default.nix.

The good news is that cargo now build without any trouble in NixOS. The bad news is that cargo now wants to fetch its registry: we can't keep it around because it's nondeterministic as hell, but if it isn't there, cargo tries to download at build time (which is not possible).

So, for now, it stuck until it's possible to build without fetching in cargo.

@jagajaga
Copy link
Member

jagajaga commented Dec 4, 2014

Maybe patch cargo and create a PR there? Explain why deteemenistic is
useful to them?

On December 4, 2014 6:13:38 PM Georges Dubus [email protected] wrote:

Update: I've started working on a new approach, which makes package
expressions nicer. The result can me seen there:
https://github.com/madjar/nixpkgs/blob/rust/pkgs/development/tools/build-managers/cargo/default.nix.

The good news is that cargo now build without any trouble in NixOS. The bad
news is that cargo now wants to fetch its registry: we can't keep it around
because it's nondeterministic as hell, but if it isn't there, cargo tries
to download at build time (which is not possible).

So, for now, it stuck until it's possible to build without fetching in cargo.


Reply to this email directly or view it on GitHub:
#4568 (comment)

@jagajaga
Copy link
Member

jagajaga commented Dec 4, 2014

Or patch cargo to use local db and pass it to it?

On December 4, 2014 6:13:38 PM Georges Dubus [email protected] wrote:

Update: I've started working on a new approach, which makes package
expressions nicer. The result can me seen there:
https://github.com/madjar/nixpkgs/blob/rust/pkgs/development/tools/build-managers/cargo/default.nix.

The good news is that cargo now build without any trouble in NixOS. The bad
news is that cargo now wants to fetch its registry: we can't keep it around
because it's nondeterministic as hell, but if it isn't there, cargo tries
to download at build time (which is not possible).

So, for now, it stuck until it's possible to build without fetching in cargo.


Reply to this email directly or view it on GitHub:
#4568 (comment)

@jagajaga
Copy link
Member

Updates? ;)

@thoughtpolice thoughtpolice added the 0.kind: enhancement Add something new label Mar 11, 2015
@madjar
Copy link
Member Author

madjar commented Mar 12, 2015

Not really. I planned to use a dirty hack to force nix to consider the result of cargo fetch as deterministic, but I didn't really have time to do anything.

It's pretty low on my todo-list, so if someone wants to give it a go, I'll be able to provide any help I can.

@wizeman
Copy link
Member

wizeman commented Apr 16, 2015

I've picked up from where @madjar left off, and I've made some improvements.

Also, I think I've finally found a good (or at least, working) solution to make cargo fetch completely deterministic.

I will keep you updated and post something up once I make some more progress in the next few days.

@madjar
Copy link
Member Author

madjar commented Apr 16, 2015

@wizeman Awesome, thanks! I can't wait to see how you solved it.

@jagajaga
Copy link
Member

Awesome! Thank you!

On 16 April 2015 15:08:10 "Ricardo M. Correia" [email protected]
wrote:

I've picked up from where @madjar left off, and I've made some improvements.

Also, I think I've finally found a good (or at least, working) solution to
make cargo fetch completely deterministic.

I will keep you updated and post something up once I make some more
progress in the next few days.


Reply to this email directly or view it on GitHub:
#4568 (comment)

@wizeman
Copy link
Member

wizeman commented Apr 21, 2015

Ok, I finally have something that works. See #7501

@madjar
Copy link
Member Author

madjar commented Apr 22, 2015

Awesome! I'll close this PR, then.

@madjar madjar closed this Apr 22, 2015
@madjar madjar deleted the rust branch September 19, 2019 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement Add something new 2.status: work-in-progress This PR isn't done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants