Replies: 1 comment
-
The biggest challenge of making something like that work is implementing the actual version resolution in a sandbox-friendly way. I don't know too much about the internals of cargo or cargo-script, but in theory it might be possible to do completely offline as long as the crates.io index is somehow pulled in as an input to the derivation and put on disk in a place that the sandboxed derivation could find it (handling git repos would get more difficult). If you can live with IFD (import-from-derivation) that might get you most of the way, but if you can't, you'd have to implement all of cargo's semver resolution rules in Nix at evaluation time which is probably a very difficult undertaking... |
Beta Was this translation helpful? Give feedback.
-
I like the idea of https://rust-script.org/ and
cargo-script
, but main problem with it I see is that when running such scripts in nix derivation, they will want to do rust compilation and will fail due to the sanbox.I'm wondering what's the best approach to making them usable. RN. the best idea I can see is to have something like
patchShebangs
, that would just pre-compile everything, kind of like whatcrane
does. Does it make sense, is doable?Does it require crane, could it be implemented as part of nixpkgs Rust infrastructure? Maybe I should ask on Nix discussion forums as well.
https://discourse.nixos.org/t/cargo-script-scripts-in-nix-derivations/42136
Beta Was this translation helpful? Give feedback.
All reactions