Closed hmac closed 2 years ago
I do not know if this will work with the new fromTOML
, but Nix has builtins.tryEval
, which returns an attribute set which will report whether the evaluation succeeded or not.
One should be careful with partially evaluated code, as tryEval
will only catch failures of executions while it is on the execution stack.
Sadly I don't think tryEval
works for fromTOML
because it's a builtin:
$ echo "not-toml" > foo
$ nix repl
Welcome to Nix version 2.3.14. Type :? for help.
nix-repl> builtins.fromTOML (builtins.readFile (./. + "/foo"))
error: while parsing a TOML string at (string):1:1: Value must follow after a '=' at line 1
nix-repl> builtins.tryEval (builtins.fromTOML (builtins.readFile (./. + "/foo")))
error: while parsing a TOML string at (string):1:19: Value must follow after a '=' at line 1
Thanks for the review!
This PR adds basic support for Rust toolchain files which are formatted as TOML. The only requirement is that they have the extension
.toml
, but that could be lifted if you know how to catch errors in Nix (I don't).As it is you can provide
{ rustToolchain = ./path/to/your-rust-toolchain.toml }
and things should just work.