flake: Switch to treefmt-nix for checks & formatting

Signed-off-by: Christoph Heiss <christoph@c8h4.io>
This commit is contained in:
Christoph Heiss 2023-11-05 23:31:44 +01:00
parent 6469447c54
commit 0fe51ed711
Signed by: c8h4
GPG key ID: 73D5E7FDEE3DE49A
2 changed files with 42 additions and 23 deletions

View file

@ -38,7 +38,8 @@
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"treefmt-nix": "treefmt-nix"
}
},
"systems": {
@ -55,6 +56,26 @@
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1698438538,
"narHash": "sha256-AWxaKTDL3MtxaVTVU5lYBvSnlspOS0Fjt8GxBgnU0Do=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "5deb8dc125a9f83b65ca86cf0c8167c46593e0b1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",

View file

@ -6,13 +6,27 @@
"github:NixOS/nixpkgs/21ad1050bf67f6a31acc38d41b7999e1a0bd0ca0"; # 31-07-2023
flake-utils.url =
"github:numtide/flake-utils/919d646de7be200f3bf08cb76ae1f09402b6f9b4"; # 11-07-2023
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, flake-utils, ... }:
outputs = { self, nixpkgs, flake-utils, treefmt-nix, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
treefmt = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
statix.enable = true;
deadnix.enable = true;
prettier.enable = true;
};
};
src = ./.;
c8h4-io = pkgs.stdenv.mkDerivation {
name = "c8h4-io-hugo";
@ -31,22 +45,11 @@
in {
checks = rec {
inherit c8h4-io;
default = c8h4-io;
c8h4-io-prettier = pkgs.stdenv.mkDerivation {
name = "c8h4-io-prettier";
inherit src;
buildInputs = with pkgs; [ nodePackages.prettier ];
buildPhase = ''
prettier --check .
'';
installPhase = ''
mkdir -p $out
'';
};
formatting = treefmt.config.build.check self;
};
formatter = treefmt.config.build.wrapper;
packages = rec {
inherit c8h4-io;
default = c8h4-io;
@ -65,13 +68,8 @@
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
deadnix
hugo
nixfmt
nodePackages.prettier
statix
];
inputsFrom = [ treefmt.config.build.devShell ];
nativeBuildInputs = with pkgs; [ hugo ];
};
});
}