diff options
author | EuAndreh <eu@euandre.org> | 2025-03-30 18:05:52 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2025-03-30 18:05:52 -0300 |
commit | 8f210b5ef0133b6ca32e18d46881c9317921da4f (patch) | |
tree | 3d9cdd34a74461d10d7b3efb9f0ca9f9884fcda8 /src/content/blog/2020/10/05/cargo2nix.adoc | |
parent | Makefile, mkdeps.sh: Silent commands that are already too big, and will get b... (diff) | |
download | euandre.org-8f210b5ef0133b6ca32e18d46881c9317921da4f.tar.gz euandre.org-8f210b5ef0133b6ca32e18d46881c9317921da4f.tar.xz |
src/content/blog/2020/10/05/: Update to asciidoc
Diffstat (limited to 'src/content/blog/2020/10/05/cargo2nix.adoc')
-rw-r--r-- | src/content/blog/2020/10/05/cargo2nix.adoc | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/src/content/blog/2020/10/05/cargo2nix.adoc b/src/content/blog/2020/10/05/cargo2nix.adoc index 1db3d0c..e99fe67 100644 --- a/src/content/blog/2020/10/05/cargo2nix.adoc +++ b/src/content/blog/2020/10/05/cargo2nix.adoc @@ -1,29 +1,19 @@ = cargo2nix: Dramatically simpler Rust in Nix -date: 2020-10-05 2 +:empty: +:swift2nix: link:./swift2nix.html +:cargo2nix: link:./cargo2nix-demo.tar.gz -layout: post +In the same vein of my earlier post on {swift2nix}[swift2nix], I was able to +quickly prototype a Rust and Cargo variation of it: {cargo2nix}[cargo2nix]. -lang: en - -ref: cargo2nix-dramatically-simpler-rust-in-nix - ---- - -In the same vein of my earlier post on -[swift2nix]({% link _articles/2020-10-05-swift2nix-run-swift-inside-nix-builds.md %}), I -was able to quickly prototype a Rust and Cargo variation of it: -[cargo2nix]. - - -The initial prototype is even smaller than swift2nix: it has only -37 lines of code. - -[cargo2nix]: https://euandre.org/static/attachments/cargo2nix.tar.gz +The initial prototype is even smaller than swift2nix: it has only 37 lines of +code. Here's how to use it (snippet taken from the repo's README): -```nix +[source,nix] +---- let niv-sources = import ./nix/sources.nix; mozilla-overlay = import niv-sources.nixpkgs-mozilla; @@ -48,33 +38,34 @@ in pkgs.stdenv.mkDerivation { touch $out ''; } -``` +---- That `cargo test` part on line 20 is what I have been fighting with every -"\*2nix" available for Rust out there. I don't want to bash any of them. All I +"*2nix" available for Rust out there. I don't want to bash any of them. All I want is to have full control of what Cargo commands to run, and the "*2nix" tool -should only setup the environment for me. Let me drive Cargo myself, no need to +should only setup the environment for me. Let me drive Cargo myself, no need to parameterize how the tool runs it for me, or even replicate its internal behaviour by calling the Rust compiler directly. Sure it doesn't support private registries or Git dependencies, but how much -bigger does it has to be to support them? Also, it doesn't support those **yet**, -there's no reason it can't be extended. I just haven't needed it yet, so I -haven't added. Patches welcome. +bigger does it has to be to support them? Also, it doesn't support those *yet*, +there's no reason it can't be extended. I just haven't needed it yet, so I +haven't added. Patches welcome. The layout of the `vendor/` directory is more explicit and public then what -swift2nix does: it is whatever the command `cargo vendor` returns. However I +swift2nix does: it is whatever the command `cargo vendor` returns. However I haven't checked if the shape of the `.cargo-checksum.json` is specified, or internal to Cargo. Try out the demo (also taken from the repo's README): -```shell +[source,shell] +---- pushd "$(mktemp -d)" wget -O- https://euandre.org/static/attachments/cargo2nix-demo.tar.gz | tar -xv cd cargo2nix-demo/ nix-build -``` +---- Report back if you wish. |