treefmt-nix
treefmt-nix copied to clipboard
mix-format
> Mix requires the Hex package manager to fetch dependencies
> Shall I install Hex? (if running non-interactively, use "mix local.hex --force") [Yn] ** (Mix) Could not find an SCM for dependency :castore from TeslaMate.MixProject
>
> treefmt: error: formatting failure: formatter '/nix/store/r2bjg78m7b7s75lwcgn69svk010j3sqb-elixir-1.17.3/bin/mix' with options '[format]' failed to apply: exit status 1
To Reproduce
programs.mix-format.enable = true;
and run check on x86_64.
See https://github.com/teslamate-org/teslamate/issues/4294
/cc @nifoc
I think I never ran into this because when you're developing, you're forced to install hex (and potentially rebar) and so treefmt always found the ones I manually installed (using the command from the error message above).
Both are packaged in nixpkgs, so theoretically there is no need to download them, but I'm not sure if there is a (good) way to make mix aware of the nix-provided hex. All I can think of is a wrapper shell script, which probably isn't ideal ...
Yes. I think we need a way to wrap the dependencies into the mix binary for this to be truly useful. There are some popular mix dependencies that influence mix format.
For the time being I added a custom isFormatted check that downloads all the deps at runtime> by wrapping mix. It's not pretty, but it works™