summaryrefslogtreecommitdiff
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
parente5e1dd731f8afa3d75149b2ba20f91173df42e4f (diff)
nix: use treefmt-nix
-rw-r--r--flake.lock23
-rw-r--r--flake.nix59
-rw-r--r--shell.nix4
-rw-r--r--treefmt.nix9
4 files changed, 49 insertions, 46 deletions
diff --git a/flake.lock b/flake.lock
index e4f3dbe..3f1bc68 100644
--- a/flake.lock
+++ b/flake.lock
@@ -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"
}
}
},
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:
diff --git a/shell.nix b/shell.nix
index 5ef2b64..9daab94 100644
--- a/shell.nix
+++ b/shell.nix
@@ -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;
+ };
+}