blob: bf139f07d9dd627c6acb72970fde292e2050503f (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
{
lib,
runCommand,
treefmt,
makeBinaryWrapper,
}:
{
name ? "treefmt-with-config",
settings ? { },
runtimeInputs ? [ ],
}:
runCommand name
{
nativeBuildInputs = [ makeBinaryWrapper ];
treefmtExe = lib.getExe treefmt;
binPath = lib.makeBinPath runtimeInputs;
passthru = { inherit runtimeInputs; };
configFile = treefmt.buildConfig {
# Wrap user's modules with a default file location
_file = "<treefmt.withConfig settings arg>";
imports = lib.toList settings;
};
inherit (treefmt) meta version;
}
''
mkdir -p $out/bin
makeWrapper \
$treefmtExe \
$out/bin/treefmt \
--prefix PATH : "$binPath" \
--add-flags "--config-file $configFile"
''
|