summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseth <[email protected]>2024-02-13 02:45:06 -0500
committerseth <[email protected]>2024-02-13 02:53:32 -0500
commitd52218cd68f7724f85aacabe5d275396291a7fcd (patch)
treeac367f83d90f05320df45c705db74180f606d948
parentca386b74ecaebaf8271ac47fa3d91ddf4779f7d2 (diff)
nix: use treefmt
-rw-r--r--flake.lock75
-rw-r--r--flake.nix21
-rw-r--r--nix/dev.nix42
3 files changed, 85 insertions, 53 deletions
diff --git a/flake.lock b/flake.lock
index e386bec..3461e2c 100644
--- a/flake.lock
+++ b/flake.lock
@@ -21,19 +21,23 @@
"type": "github"
}
},
- "flake-compat": {
- "flake": false,
+ "flake-parts": {
+ "inputs": {
+ "nixpkgs-lib": [
+ "nixpkgs"
+ ]
+ },
"locked": {
- "lastModified": 1696426674,
- "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
- "owner": "edolstra",
- "repo": "flake-compat",
- "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
+ "lastModified": 1706830856,
+ "narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=",
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f",
"type": "github"
},
"original": {
- "owner": "edolstra",
- "repo": "flake-compat",
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
"type": "github"
}
},
@@ -58,7 +62,7 @@
"gitignore": {
"inputs": {
"nixpkgs": [
- "pre-commit",
+ "pre-commit-hooks-nix",
"nixpkgs"
]
},
@@ -112,29 +116,9 @@
"type": "github"
}
},
- "parts": {
- "inputs": {
- "nixpkgs-lib": [
- "nixpkgs"
- ]
- },
- "locked": {
- "lastModified": 1706830856,
- "narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=",
- "owner": "hercules-ci",
- "repo": "flake-parts",
- "rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f",
- "type": "github"
- },
- "original": {
- "owner": "hercules-ci",
- "repo": "flake-parts",
- "type": "github"
- }
- },
- "pre-commit": {
+ "pre-commit-hooks-nix": {
"inputs": {
- "flake-compat": "flake-compat",
+ "flake-compat": [],
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": [
@@ -181,11 +165,12 @@
"root": {
"inputs": {
"fenix": "fenix",
+ "flake-parts": "flake-parts",
"naersk": "naersk",
"nixpkgs": "nixpkgs",
- "parts": "parts",
- "pre-commit": "pre-commit",
- "procfile-nix": "procfile-nix"
+ "pre-commit-hooks-nix": "pre-commit-hooks-nix",
+ "procfile-nix": "procfile-nix",
+ "treefmt-nix": "treefmt-nix"
}
},
"rust-analyzer-src": {
@@ -219,6 +204,26 @@
"repo": "default",
"type": "github"
}
+ },
+ "treefmt-nix": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1707300477,
+ "narHash": "sha256-qQF0fEkHlnxHcrKIMRzOETnRBksUK048MXkX0SOmxvA=",
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "rev": "ac599dab59a66304eb511af07b3883114f061b9d",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "type": "github"
+ }
}
},
"root": "root",
diff --git a/flake.nix b/flake.nix
index 9405636..618eb5a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -9,7 +9,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
- parts = {
+ flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
@@ -24,10 +24,18 @@
inputs.nixpkgs.follows = "nixpkgs";
};
- pre-commit = {
+ pre-commit-hooks-nix = {
url = "github:cachix/pre-commit-hooks.nix";
+ inputs = {
+ nixpkgs.follows = "nixpkgs";
+ nixpkgs-stable.follows = "nixpkgs";
+ flake-compat.follows = "";
+ };
+ };
+
+ treefmt-nix = {
+ url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
- inputs.nixpkgs-stable.follows = "nixpkgs";
};
procfile-nix = {
@@ -36,11 +44,12 @@
};
};
- outputs = {parts, ...} @ inputs:
- parts.lib.mkFlake {inherit inputs;} {
+ outputs = inputs:
+ inputs.flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
- inputs.pre-commit.flakeModule
+ inputs.pre-commit-hooks-nix.flakeModule
inputs.procfile-nix.flakeModule
+ inputs.treefmt-nix.flakeModule
./nix/ci.nix
./nix/deployment.nix
diff --git a/nix/dev.nix b/nix/dev.nix
index ac0fac9..d9f15d4 100644
--- a/nix/dev.nix
+++ b/nix/dev.nix
@@ -5,19 +5,39 @@
config,
self',
...
- }: {
- pre-commit.settings = {
- hooks = {
- actionlint.enable = true;
- ${self'.formatter.pname}.enable = true;
- deadnix.enable = true;
- nil.enable = true;
- prettier.enable = true;
- rustfmt.enable = true;
- statix.enable = true;
+ }: let
+ enableAll = lib.flip lib.genAttrs (lib.const {enable = true;});
+ in {
+ treefmt = {
+ projectRootFile = "flake.nix";
+
+ programs = enableAll [
+ "alejandra"
+ "deadnix"
+ "prettier"
+ "rustfmt"
+ ];
+
+ settings.global = {
+ excludes = [
+ "./target"
+ "./flake.lock"
+ "./Cargo.lock"
+ ];
};
};
+ pre-commit.settings = {
+ settings.treefmt.package = config.treefmt.build.wrapper;
+
+ hooks = enableAll [
+ "actionlint"
+ "nil"
+ "statix"
+ "treefmt"
+ ];
+ };
+
procfiles.daemons.processes = {
redis = lib.getExe' pkgs.redis "redis-server";
};
@@ -47,7 +67,5 @@
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
};
-
- formatter = pkgs.alejandra;
};
}