diff --git a/README.md b/README.md index 9b9c6cc..52324aa 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ A nixos module to make buildbot a proper Nix-CI. -For an example checkout the [example](./examples/default.nix) and the module descriptions for [master](./nix/master.nix) and [worker](./nix/worker.nix). +For an example checkout the [example](./examples/default.nix) and the module +descriptions for [master](./nix/master.nix) and [worker](./nix/worker.nix). This project is still in early stage and many APIs might change over time. diff --git a/flake.lock b/flake.lock index 83e2df4..4b5fe22 100644 --- a/flake.lock +++ b/flake.lock @@ -39,7 +39,28 @@ "root": { "inputs": { "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1694528738, + "narHash": "sha256-aWMEjib5oTqEzF9f3WXffC1cwICo6v/4dYKjwNktV8k=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "7a49c388d7a6b63bb551b1ddedfa4efab8f400d8", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } } }, diff --git a/nix/treefmt/flake-module.nix b/nix/treefmt/flake-module.nix new file mode 100644 index 0000000..9f2c05e --- /dev/null +++ b/nix/treefmt/flake-module.nix @@ -0,0 +1,29 @@ +{ inputs, ... }: { + imports = [ + inputs.treefmt-nix.flakeModule + ]; + perSystem = { config, pkgs, ... }: { + treefmt = { + projectRootFile = ".git/config"; + programs.nixpkgs-fmt.enable = true; + programs.shellcheck.enable = true; + programs.deno.enable = true; + settings.formatter.shellcheck.options = [ "-s" "bash" ]; + + programs.mypy.enable = true; + programs.mypy.directories."." = { }; + settings.formatter.python = { + command = "sh"; + options = [ + "-eucx" + '' + ${pkgs.ruff}/bin/ruff --fix "$@" + ${pkgs.python3.pkgs.black}/bin/black "$@" + '' + "--" # this argument is ignored by bash + ]; + includes = [ "*.py" ]; + }; + }; + }; +}