diff options
| author | seth <[email protected]> | 2024-07-16 22:38:59 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2024-07-16 22:45:50 -0400 |
| commit | cf106afeac4f9d430216d6dddb79091f97da911f (patch) | |
| tree | 7d1655cb3998842a9e7f97b8dfaab9bf3a72e291 | |
| parent | e5e1dd731f8afa3d75149b2ba20f91173df42e4f (diff) | |
nix: use treefmt-nix
| -rw-r--r-- | flake.lock | 23 | ||||
| -rw-r--r-- | flake.nix | 59 | ||||
| -rw-r--r-- | shell.nix | 4 | ||||
| -rw-r--r-- | treefmt.nix | 9 |
4 files changed, 49 insertions, 46 deletions
@@ -18,7 +18,28 @@ }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1721059077, + "narHash": "sha256-gCICMMX7VMSKKt99giDDtRLkHJ0cwSgBtDijJAqTlto=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "0fb28f237f83295b4dd05e342f333b447c097398", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } } }, @@ -1,10 +1,21 @@ { description = "seth's website"; - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; outputs = - { self, nixpkgs }: + { + self, + nixpkgs, + treefmt-nix, + }: let inherit (nixpkgs) lib; systems = [ @@ -16,46 +27,12 @@ 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: - let - pkgs = nixpkgsFor.${system}; - in - { - check-lint = - pkgs.runCommand "check-lint" - { - nativeBuildInputs = [ - pkgs.actionlint - pkgs.deadnix - pkgs.statix - ]; - } - '' - echo "running actionlint..." - actionlint ${self}/.github/workflows/* - - echo "running deadnix..." - deadnix --fail ${self} - - echo "running statix..." - statix check ${self} - - touch $out - ''; - - check-formatting = - pkgs.runCommand "check-formatting" { nativeBuildInputs = [ pkgs.nixfmt-rfc-style ]; } - '' - echo "running nixfmt..." - nixfmt --check ${self} - - touch $out - ''; - } - ); + checks = forAllSystems (system: { + treefmt = treefmtFor.${system}.config.build.check self; + }); devShells = forAllSystems (system: { default = import ./shell.nix { @@ -65,7 +42,7 @@ }; }); - formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style); + formatter = forAllSystems (system: treefmtFor.${system}.config.build.wrapper); packages = forAllSystems ( system: @@ -11,11 +11,7 @@ pkgs.mkShellNoCC { packages = [ pkgs.zola - - # linters + formatters formatter pkgs.actionlint - pkgs.nodePackages.alex - pkgs.nodePackages.prettier ]; } diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..272d8f8 --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,9 @@ +{ + projectRootFile = ".git/config"; + + programs = { + deadnix.enable = true; + nixfmt.enable = true; + statix.enable = true; + }; +} |
