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

writers: add writeRust and deduplicate binary stripping #109050

Merged
merged 3 commits into from Jan 12, 2021

Conversation

xaverdh
Copy link
Contributor

@xaverdh xaverdh commented Jan 11, 2021

Motivation for this change

I want to use rust code in nixpkgs, but there sure are other use cases.

@Lassulus
Copy link
Member

I should probably also quote more variables generally in the nix-writers. just to have a uniform style (more quoting is better than less quoting)

Do we maybe want to add an optional strip argument to writeHaskell, writeC, writeRust? and inherit it in the call to makeBinWriter?

@SuperSandro2000
Copy link
Member

more quoting is better than less quoting

At least the standard $out does not require quoting because the path can't contain spaces, new lines, etc.

@xaverdh
Copy link
Contributor Author

xaverdh commented Jan 12, 2021

I should probably also quote more variables generally in the nix-writers. just to have a uniform style (more quoting is better than less quoting)

Do we maybe want to add an optional strip argument to writeHaskell, writeC, writeRust? and inherit it in the call to makeBinWriter?

I added a strip argument to those, good idea :-)
i wish we had "rustcWithPackages" or something, but I am not familiar enough with rust internals to write that yet, and its out of scope of this pr I think.

@Lassulus
Copy link
Member

ah, can you also add a test (at least a bin one) into https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/writers/test.nix ? simple would also be cool when you figure out how to use libraries :)

@xaverdh
Copy link
Contributor Author

xaverdh commented Jan 12, 2021

ah, can you also add a test (at least a bin one) into https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/writers/test.nix ? simple would also be cool when you figure out how to use libraries :)

I added a trivial test. The thing with libraries is that the rust world universally uses cargo for that, so if you need libs, you are probably better off using buildRustPackage proper.

@Lassulus Lassulus merged commit ec4a166 into NixOS:master Jan 12, 2021
@Profpatsch
Copy link
Member

I’ve been using these rust writers with some success:
https://cs.tvl.fyi/depot@1261616bff04b6a5cb966778da8a336245c08979/-/blob/users/Profpatsch/writers/default.nix#L75-112

They are just wrappers around buildRustPackage, which has the advantage that they can use anything created by buildRustPackage as a dependency, e.g. see the tests in https://cs.tvl.fyi/depot@1261616bff04b6a5cb966778da8a336245c08979/-/blob/users/Profpatsch/writers/tests.nix

@xaverdh xaverdh deleted the rust-writer branch January 12, 2021 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants