Skip to content

Commit

Permalink
chore: treefmt config file
Browse files Browse the repository at this point in the history
  • Loading branch information
o-az committed Sep 25, 2024
1 parent 4076b0f commit b5d2fc1
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 141 deletions.
1 change: 0 additions & 1 deletion docs/openapi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ _: {
{
pkgs,
unstablePkgs,
self',
openapi,
ensureAtRepositoryRoot,
mkCi,
Expand Down
144 changes: 8 additions & 136 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -571,142 +571,14 @@
PROTOC = "${pkgs.protobuf}/bin/protoc";
};
# https://flake.parts/options/treefmt-nix#opt-perSystem.treefmt
treefmt = {
package = unstablePkgs.treefmt;
projectRootFile = "flake.nix";
programs = {
gofmt = {
enable = true;
package = goPkgs.go;
};
rustfmt = {
enable = true;
package = rust.toolchains.dev;
};
taplo = {
enable = true;
};
biome = {
enable = true;
package = biome;
};
yamlfmt = {
enable = true;
package = unstablePkgs.yamlfmt;
};
mdformat = {
enable = true;
package = unstablePkgs.mdformat;
};
nixfmt-rfc-style = {
enable = true;
package = unstablePkgs.nixfmt-rfc-style;
};
statix = {
enable = true;
package = unstablePkgs.statix;
};
deadnix = {
enable = true;
package = unstablePkgs.deadnix;
};
};
settings = {
formatter = {
mdformat.options = [ "--number" ];
deadnix.options = [ "--no-lambda-pattern-names" ];
yamlfmt.options = [
"-formatter"
"retain_line_breaks=true"
];
biome = {
options = [
"check"
"--config-path"
"./biome.json"
];
includes = [
"*.ts"
"*.js"
"*.cjs"
"*.cts"
"*.mts"
"*.mjs"
"*.jsx"
"*.tsx"
"*.d.ts"
"*.d.mts"
"*.d.cts"
"*.html"
"*.vue"
"*.css"
"*.json"
"*.jsonc"
"*.astro"
"*.svelte"
"*.graphql"
];
};
sort =
let
filesToSort = [ "dictionary.txt" ];
in
{

command =
let
# This sort is consistent across machines because we set the locale.
sort = pkgs.symlinkJoin {
name = "sort";
paths = [ pkgs.coreutils ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/sort \
--set LC_ALL C \
--set LC_COLLATE C
'';
};
in
"${sort}/bin/sort";
options = [
"-uo"
] ++ filesToSort;
includes = filesToSort;
};
forge = {
command =
let
forge = pkgs.symlinkJoin {
name = "forge";
paths = [ pkgs.foundry-bin ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/forge \
--set FOUNDRY_CONFIG "${./foundry.toml}"
'';
};
in
"${forge}/bin/forge";
options = [ "fmt" ];
includes = [ "*.sol" ];
};
};
global = {
hidden = true;
excludes = [
"_/**"
"*.ttf"
"*.png"
".git/**"
"**/.sqlx/**"
"**/vendor/**"
"*.splinecode"
"**/generated/**"
".github/**/*.md"
"uniond/docs/static/**"
];
};
};
treefmt = import ./treefmt.nix {
inherit
pkgs
unstablePkgs
goPkgs
rust
biome
;
};
};
};
Expand Down
138 changes: 138 additions & 0 deletions treefmt.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# https://flake.parts/options/treefmt-nix#opt-perSystem.treefmt
{
pkgs,
rust,
biome,
goPkgs,
unstablePkgs,
}:

{
package = unstablePkgs.treefmt;
projectRootFile = "treefmt.nix";
programs = {
gofmt = {
enable = true;
package = goPkgs.go;
};
rustfmt = {
enable = true;
package = rust.toolchains.dev;
};
taplo.enable = true;
biome = {
enable = true;
package = biome;
};
yamlfmt = {
enable = true;
package = unstablePkgs.yamlfmt;
};
mdformat = {
enable = true;
package = unstablePkgs.mdformat;
};
shellcheck = {
enable = true;
package = unstablePkgs.shellcheck;
};
nixfmt-rfc-style = {
enable = true;
package = unstablePkgs.nixfmt-rfc-style;
};
statix = {
enable = true;
package = unstablePkgs.statix;
};
deadnix = {
enable = true;
package = unstablePkgs.deadnix;
};
};
settings = {
formatter = {
nixfmt-rfc-style = {
options = [ ];
includes = [ "*.nix" ];
};
statix.options = [ "explain" ];
mdformat.options = [ "--number" ];
deadnix.options = [ "--no-lambda-pattern-names" ];
shellcheck.options = [
"--shell=bash"
"--check-sourced"
];
yamlfmt.options = [
"-formatter"
"retain_line_breaks=true"
];
biome =
let
biomeJsonConfig = builtins.fromJSON (builtins.readFile ./biome.json);
in
{
options = [
"check"
"--config-path"
"./biome.json"
];
includes = biomeJsonConfig.files.include;
};
sort =
let
filesToSort = [ "dictionary.txt" ];
in
{
command =
let
sort = pkgs.symlinkJoin {
name = "sort";
paths = [ pkgs.coreutils ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/sort \
--set LC_ALL C \
--set LC_COLLATE C
'';
};
in
"${sort}/bin/sort";
options = [ "-uo" ] ++ filesToSort;
includes = filesToSort;
};
forge = {
command =
let
forge = pkgs.symlinkJoin {
name = "forge";
paths = [ pkgs.foundry-bin ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/forge \
--set FOUNDRY_CONFIG "${./foundry.toml}"
'';
};
in
"${forge}/bin/forge";
options = [ "fmt" ];
includes = [ "*.sol" ];
};
};
global = {
hidden = true;
excludes = [
"_/**"
"*.ttf"
"*.png"
".git/**"
"**/.sqlx/**"
"**/vendor/**"
"*.splinecode"
"**/generated/**"
".github/**/*.sh"
".github/**/*.md"
"uniond/docs/static/**"
];
};
};
}
2 changes: 0 additions & 2 deletions typescript-sdk/typescript-sdk.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ _: {
{
pkgs,
unstablePkgs,
lib,
ensureAtRepositoryRoot,
mkCi,
...
}:
{
Expand Down
4 changes: 2 additions & 2 deletions unionvisor/src/testdata/test_create_and_read/bins/bin.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
set -e

mkdir -p $4
printf %s '{"name": "upgrade1", "height": 123}' > $4/upgrade-info.json
mkdir -p "$4"
printf %s '{"name": "upgrade1", "height": 123}' > "$4"/upgrade-info.json

0 comments on commit b5d2fc1

Please sign in to comment.