1{
2 lib,
3 pkgs,
4 config,
5 options,
6 ...
7}:
8{
9 options.result = lib.mkOption {
10 type = lib.types.package;
11 description = ''
12 The wrapped treefmt package.
13 '';
14 readOnly = true;
15 internal = true;
16 };
17
18 config.result =
19 pkgs.runCommand config.name
20 {
21 nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
22 env = {
23 inherit (config) configFile;
24 binPath = lib.makeBinPath config.runtimeInputs;
25 };
26 passthru = {
27 inherit (config) runtimeInputs;
28 inherit config options;
29 };
30 inherit (config.package) meta version;
31 }
32 ''
33 mkdir -p $out/bin
34 makeWrapper \
35 ${lib.getExe config.package} \
36 $out/bin/treefmt \
37 --prefix PATH : "$binPath" \
38 --add-flags "--config-file $configFile"
39 '';
40}