Skip to content

Commit 2c9a8ff

Browse files
committed
feat(nix): add nixfmt-rfc-style to dev dependencies and lefthook
Add nixfmt-rfc-style as a development dependency in the Nix flake and configure lefthook to automatically format .nix files on pre-commit. Uses `nix develop --command` to run nixfmt from the devShell context, ensuring consistent Nix code formatting across the project.
1 parent aa39a39 commit 2c9a8ff

2 files changed

Lines changed: 23 additions & 15 deletions

File tree

flake.nix

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,34 @@
66
flake-parts.url = "github:hercules-ci/flake-parts";
77
};
88

9-
outputs = inputs@{ flake-parts, ... }:
9+
outputs =
10+
inputs@{ flake-parts, ... }:
1011
flake-parts.lib.mkFlake { inherit inputs; } {
1112
systems = [
1213
"x86_64-linux"
1314
"aarch64-linux"
1415
"aarch64-darwin"
1516
];
1617

17-
perSystem = { pkgs, ... }: {
18-
devShells.default = pkgs.mkShell {
19-
buildInputs = with pkgs; [
20-
pnpm_10
21-
];
18+
perSystem =
19+
{ pkgs, ... }:
20+
{
21+
devShells.default = pkgs.mkShell {
22+
buildInputs = with pkgs; [
23+
pnpm_10
24+
nixfmt-rfc-style
25+
];
2226

23-
shellHook = ''
24-
echo "StackOne AI Node SDK development environment"
27+
shellHook = ''
28+
echo "StackOne AI Node SDK development environment"
2529
26-
# Install dependencies only if node_modules/.pnpm/lock.yaml is older than pnpm-lock.yaml
27-
if [ ! -f node_modules/.pnpm/lock.yaml ] || [ pnpm-lock.yaml -nt node_modules/.pnpm/lock.yaml ]; then
28-
echo "📦 Installing dependencies..."
29-
pnpm install --frozen-lockfile
30-
fi
31-
'';
30+
# Install dependencies only if node_modules/.pnpm/lock.yaml is older than pnpm-lock.yaml
31+
if [ ! -f node_modules/.pnpm/lock.yaml ] || [ pnpm-lock.yaml -nt node_modules/.pnpm/lock.yaml ]; then
32+
echo "📦 Installing dependencies..."
33+
pnpm install --frozen-lockfile
34+
fi
35+
'';
36+
};
3237
};
33-
};
3438
};
3539
}

lefthook.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ pre-commit:
99
glob: '*'
1010
run: pnpm oxfmt --no-error-on-unmatched-pattern {staged_files}
1111
stage_fixed: true
12+
- name: nixfmt
13+
glob: '*.nix'
14+
run: nix develop --command nixfmt {staged_files}
15+
stage_fixed: true
1216

1317
pre-push:
1418
jobs:

0 commit comments

Comments
 (0)