blob: 583d19dd91eacd969592f3c1b31b7eb0904f3a05 (
plain) (
tree)
|
|
#
msgid ""
msgstr ""
msgid ""
"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](https://euandre.org/git/cargo2nix/)."
msgstr ""
msgid ""
"The initial prototype is even smaller than swift2nix: it has only [37 lines "
"of "
"code](https://euandre.org/git/cargo2nix/tree/default.nix?id=472dde8898296c8b6cffcbd10b3b2c3ba195846d)."
msgstr ""
msgid "Here's how to use it (snippet taken from the repo's README):"
msgstr ""
msgid ""
"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 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 parameterize how the tool runs it for me, or even "
"replicate its internal behaviour by calling the Rust compiler directly."
msgstr ""
msgid ""
"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."
msgstr ""
msgid ""
"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"
" haven't checked if the shape of the `.cargo-checksum.json` is specified, or"
" internal to Cargo."
msgstr ""
msgid "Try out the demo (also taken from the repo's README):"
msgstr ""
msgid "Report back if you wish. Again, patches welcome."
msgstr ""
msgid ""
"let\n"
" niv-sources = import ./nix/sources.nix;\n"
" mozilla-overlay = import niv-sources.nixpkgs-mozilla;\n"
" pkgs = import niv-sources.nixpkgs { overlays = [ mozilla-overlay ]; };\n"
" src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;\n"
" cargo2nix = pkgs.callPackage niv-sources.cargo2nix {\n"
" lockfile = ./Cargo.lock;\n"
" };\n"
"in pkgs.stdenv.mkDerivation {\n"
" inherit src;\n"
" name = \"cargo-test\";\n"
" buildInputs = [ pkgs.latest.rustChannels.nightly.rust ];\n"
" phases = [ \"unpackPhase\" \"buildPhase\" ];\n"
" buildPhase = ''\n"
" # Setup dependencies path to satisfy Cargo\n"
" mkdir .cargo/\n"
" ln -s ${cargo2nix.env.cargo-config} .cargo/config\n"
" ln -s ${cargo2nix.env.vendor} vendor\n"
"\n"
" # Run the tests\n"
" cargo test\n"
" touch $out\n"
" '';\n"
"}\n"
msgstr ""
msgid ""
"pushd \"$(mktemp -d)\"\n"
"git clone https://euandre.org/git/cargo2nix-demo\n"
"cd cargo2nix-demo/\n"
"nix-build\n"
msgstr ""
msgid "title: \"cargo2nix: Dramatically simpler Rust in Nix\""
msgstr ""
msgid "date: 2020-10-05 2"
msgstr ""
msgid "layout: post"
msgstr ""
msgid "lang: en"
msgstr ""
msgid "ref: cargo2nix-dramatically-simpler-rust-in-nix"
msgstr ""
#~ msgid ""
#~ "title: \"cargo2nix: Dramatically simpler Rust in Nix\"\n"
#~ "date: 2020-10-05 2\n"
#~ "layout: post\n"
#~ "lang: en\n"
#~ "ref: cargo2nix-dramatically-simpler-rust-in-nix\n"
#~ "eu_categories: mediator"
#~ msgstr ""
#~ msgid ""
#~ "title: \"cargo2nix: Dramatically simpler Rust in Nix\"\n"
#~ "date: 2020-10-05 2\n"
#~ "layout: post\n"
#~ "lang: en\n"
#~ "ref: cargo2nix-dramatically-simpler-rust-in-nix\n"
#~ "category: mediator"
#~ msgstr ""
|