| 1 | { pkgs, ... }: |
| 2 | let |
| 3 | runtimeInputs = with pkgs; [ |
| 4 | # include only a couple of formatters by default |
| 5 | clang-tools |
| 6 | deno |
| 7 | dprint |
| 8 | nixfmt |
| 9 | prettierd # autofmt only runs on a local build of prettier |
| 10 | rustfmt |
| 11 | zig |
| 12 | ]; |
| 13 | in |
| 14 | pkgs.writeTextFile { |
| 15 | name = "autofmt"; |
| 16 | destination = "/bin/autofmt"; |
| 17 | executable = true; |
| 18 | text = |
| 19 | builtins.replaceStrings |
| 20 | [ "#!/usr/bin/env node" ] |
| 21 | [ |
| 22 | '' |
| 23 | #!${pkgs.nodejs}/bin/node |
| 24 | process.env.PATH = "${pkgs.lib.makeBinPath runtimeInputs}:" + (process.env.PATH ?? "");'' |
| 25 | ] |
| 26 | (builtins.readFile ./autofmt.js); |
| 27 | } |