Programmatic editing of `flake.nix`

I have a nix flake with information in the inputs (precise revisions) that I actually want to obtain from somewhere else. Unfortunately, I cannot use nix (the language) to calculate the inputs of a flake, e.g. using builtins.fromJSON. So the next-best thing seem to be to write a tool that edits the flake.nix.

Before I reach to perl and regex, is there maybe already a tool/library/whatever out there that I can use to change the URLs of a flake input?

1 Like

If you can comfortably read Rust, you could look at what the fh CLI from DetSys does:

The actual command behavior is tied specifically to pulling inputs from FlakeHub which may or may not suit your goals.

1 Like