diff options
| -rw-r--r-- | flake.lock | 23 | ||||
| -rw-r--r-- | flake.nix | 19 | ||||
| -rw-r--r-- | treefmt.nix | 11 |
3 files changed, 50 insertions, 3 deletions
@@ -18,7 +18,28 @@ }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719887753, + "narHash": "sha256-p0B2r98UtZzRDM5miGRafL4h7TwGRC4DII+XXHDHqek=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "bdb6355009562d8f9313d9460c0d3860f525bc6c", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } } }, @@ -8,10 +8,20 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + # this can be removed with `inputs.treefmt-nix.follows = ""` + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = - { nixpkgs, ... }: + { + self, + nixpkgs, + treefmt-nix, + }: let inherit (nixpkgs) lib; systems = [ @@ -23,8 +33,13 @@ forAllSystems = lib.genAttrs systems; nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system}); + treefmtFor = forAllSystems (system: treefmt-nix.lib.evalModule nixpkgsFor.${system} ./treefmt.nix); in { + checks = forAllSystems (system: { + treefmt = treefmtFor.${system}.config.build.check self; + }); + packages = forAllSystems ( system: let @@ -43,7 +58,7 @@ pkgs' // { default = pkgs'.treefetch; } ); - formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style); + formatter = forAllSystems (system: treefmtFor.${system}.config.build.wrapper); templates = import ./templates; }; diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..a02473d --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,11 @@ +{ + projectRootFile = ".git/config"; + + # TODO: add actionlint + # https://github.com/numtide/treefmt-nix/pull/146 + programs = { + deadnix.enable = true; + nixfmt-rfc-style.enable = true; + statix.enable = true; + }; +} |
