Skip to content

Commit db0afd5

Browse files
chore: overhaul nix flake
Overhauls the nix flake to no longer use flake-utils , adds pre-commit-hooks, and writes the currently used `node --version` to an `.nvmrc`
1 parent bacbf2a commit db0afd5

File tree

4 files changed

+128
-31
lines changed

4 files changed

+128
-31
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.pre-commit-config.yaml
12
.direnv/
23
coverage/
34
dist/

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
coverage/
22
dist/
3-
package-lock.json
3+
flake.lock

flake.lock

Lines changed: 85 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,53 @@
11
{
22
description = "api-ts";
3-
43
inputs = {
54
nixpkgs.url = "github:nixos/nixpkgs";
6-
flake-utils.url = "github:numtide/flake-utils";
5+
pre-commit-hooks = {
6+
url = "github:cachix/pre-commit-hooks.nix";
7+
inputs = {
8+
nixpkgs.follows = "nixpkgs";
9+
};
10+
};
711
};
812

913
outputs = {
1014
self,
1115
nixpkgs,
12-
flake-utils,
13-
}: (
14-
flake-utils.lib.eachDefaultSystem (
15-
system: (
16-
let
17-
pkgs = nixpkgs.legacyPackages.${system};
18-
in {
19-
devShell = pkgs.mkShell {
20-
name = "api-ts-shell";
16+
pre-commit-hooks,
17+
}: let
18+
forEachSystem = nixpkgs.lib.genAttrs [
19+
"aarch64-darwin"
20+
"aarch64-linux"
21+
"x86_64-darwin"
22+
"x86_64-linux"
23+
];
24+
in {
25+
checks = forEachSystem (system: let
26+
pre-commit-check = pre-commit-hooks.lib.${system}.run {
27+
src = ./.;
28+
hooks = {
29+
actionlint.enable = true;
30+
alejandra.enable = true;
31+
prettier.enable = true;
32+
};
33+
};
34+
in {
35+
inherit pre-commit-check;
36+
});
2137

22-
packages = with pkgs; [
23-
nodejs
24-
];
38+
devShells = forEachSystem (system: let
39+
pkgs = nixpkgs.legacyPackages.${system};
40+
in {
41+
default = pkgs.mkShell {
42+
packages = with pkgs; [
43+
nodejs
44+
];
2545

26-
shellHook = ''
27-
export PATH="$(pwd)/node_modules/.bin:$PATH"
28-
'';
29-
};
30-
}
31-
)
32-
)
33-
);
46+
shellHook = ''
47+
${self.checks.${system}.pre-commit-check.shellHook}
48+
export PATH="$(pwd)/node_modules/.bin:$PATH"
49+
'';
50+
};
51+
});
52+
};
3453
}

0 commit comments

Comments
 (0)