46 lines
1.0 KiB
Nix
46 lines
1.0 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
config,
|
|
options,
|
|
...
|
|
}:
|
|
{
|
|
options.result = lib.mkOption {
|
|
type = lib.types.package;
|
|
description = ''
|
|
The wrapped treefmt package.
|
|
'';
|
|
readOnly = true;
|
|
internal = true;
|
|
};
|
|
|
|
config.result = pkgs.symlinkJoin (finalAttrs: {
|
|
pname = config.name;
|
|
inherit (config.package) meta version;
|
|
nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
|
|
paths = [ config.package ];
|
|
env = {
|
|
inherit (config) configFile;
|
|
binPath = lib.makeBinPath config.runtimeInputs;
|
|
};
|
|
passthru = {
|
|
inherit (config) runtimeInputs;
|
|
inherit config options;
|
|
check = pkgs.callPackage ../check-wrapper.nix {
|
|
wrapper = finalAttrs.finalPackage;
|
|
};
|
|
};
|
|
postBuild =
|
|
let
|
|
wrapPrefixPathArgument = lib.optionalString (
|
|
config.runtimeInputs != [ ]
|
|
) "--prefix PATH : \"$binPath\"";
|
|
in
|
|
''
|
|
wrapProgram "$out/bin/treefmt" \
|
|
--add-flags "--config-file $configFile " ${wrapPrefixPathArgument}
|
|
'';
|
|
});
|
|
}
|