Skip to content

writers: add writeRust and deduplicate binary stripping#109050

Merged
Lassulus merged 3 commits intoNixOS:masterfrom
xaverdh:rust-writer
Jan 12, 2021
Merged

writers: add writeRust and deduplicate binary stripping#109050
Lassulus merged 3 commits intoNixOS:masterfrom
xaverdh:rust-writer

Conversation

@xaverdh
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Jan 11, 2021
@xaverdh
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants