What I want is to calculate the URL automatically based on the version of rusty_v8 that is used in the Cargo.lock. Currently, I am getting the following error:
error:
… while evaluating flake attribute 'url'
at /nix/store/dmm4m3j9cl00pr1fblxz34415lgh3bi1-source/flake.nix:10:7:
9| rusty_v8 = {
10| url = ("https://github.com/denoland/rusty_v8/releases/download/"
| ^
11| + (builtins.head (builtins.filter (p: p.name == "v8") ((builtins.fromTOML (builtins.readFile ./Cargo.lock)).package))).version
error: expected a string or a path but got a thunk at /nix/store/dmm4m3j9cl00pr1fblxz34415lgh3bi1-source/flake.nix:10:7
I understand that flake.nix is just a subset of nix (the code to parse the toml works in REPL). Any suggestions on how to fix this?
Correct, so there’s your answer. It’s explicitly disallowed.
Don’t use flakes for this, or write the string out.
Or use some kind of pre-processor to generate the flake.nix, but that just seems atrocious ux-wise.
This seems like something you’d rather have outside of the inputs, since it’s entirely dependent on an external lock file. Move it to whatever is using it in outputs.