summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorseth <[email protected]>2024-07-16 22:38:59 -0400
committerseth <[email protected]>2024-07-16 22:45:50 -0400
commitcf106afeac4f9d430216d6dddb79091f97da911f (patch)
tree7d1655cb3998842a9e7f97b8dfaab9bf3a72e291 /flake.nix
parente5e1dd731f8afa3d75149b2ba20f91173df42e4f (diff)
nix: use treefmt-nix
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix59
1 files changed, 18 insertions, 41 deletions
diff --git a/flake.nix b/flake.nix
index 3366a2a..0b705d1 100644
--- a/flake.nix
+++ b/flake.nix
@@ -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: