Brian McGee
5711caebb9
Introduces a `--walk` flag which can be used to tell `treefmt` how to traverse the directory specified by `--tree-root`. By default, it will attempt to use `git ls-files`. If this fails, it falls back to using the filesystem. You can explicitly traverse the filesystem instead of using git by providing `--walk filesystem`. Close #1 Reviewed-on: #19 Reviewed-by: Jonas Chevalier <zimbatm@noreply.git.numtide.com> Co-authored-by: Brian McGee <brian@bmcgee.ie> Co-committed-by: Brian McGee <brian@bmcgee.ie>
57 lines
1.2 KiB
Nix
57 lines
1.2 KiB
Nix
{inputs, ...}: {
|
|
imports = [
|
|
inputs.flake-parts.flakeModules.easyOverlay
|
|
];
|
|
|
|
perSystem = {
|
|
self',
|
|
inputs',
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}: {
|
|
packages = rec {
|
|
treefmt = inputs'.gomod2nix.legacyPackages.buildGoApplication rec {
|
|
pname = "treefmt";
|
|
version = "0.0.1+dev";
|
|
|
|
# ensure we are using the same version of go to build with
|
|
inherit (pkgs) go;
|
|
|
|
src = ../.;
|
|
modules = ../gomod2nix.toml;
|
|
|
|
ldflags = [
|
|
"-X 'build.Name=${pname}'"
|
|
"-X 'build.Version=${version}'"
|
|
];
|
|
|
|
# needed for git ls-files
|
|
buildInputs = [pkgs.git];
|
|
|
|
nativeBuildInputs =
|
|
# needed for git ls-files
|
|
[pkgs.git]
|
|
# we need some formatters available for the tests
|
|
++ (import ./formatters.nix pkgs);
|
|
|
|
preCheck = ''
|
|
XDG_CACHE_HOME=$(mktemp -d)
|
|
export XDG_CACHE_HOME
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "treefmt: one CLI to format your repo";
|
|
homepage = "https://git.numtide.com/numtide/treefmt";
|
|
license = licenses.mit;
|
|
mainProgram = "treefmt";
|
|
};
|
|
};
|
|
|
|
default = treefmt;
|
|
};
|
|
|
|
overlayAttrs = self'.packages;
|
|
};
|
|
}
|