Skip to content

Commit b5defd8

Browse files
authored
refactor(nix): migrate from flake-utils to flake-parts (#250)
* fix(ci): move install to nix action * refactor(nix): migrate from flake-utils to flake-parts Replace flake-utils with flake-parts for a more modular and type-safe Nix flake configuration. flake-parts uses the NixOS module system pattern, providing better extensibility and composability. Key changes: - Replace flake-utils input with flake-parts - Use mkFlake with perSystem pattern instead of eachDefaultSystem - Explicitly declare supported systems (x86_64-linux, aarch64-linux, aarch64-darwin) - Remove x86_64-darwin from supported systems as it is no longer needed Benefits of flake-parts: - NixOS-style module system for flake configuration - Type-safe options with better error messages - Support for advanced features like partitions and flakeModules - More maintainable structure for complex flake configurations * 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 2f0660d commit b5defd8

File tree

3 files changed

+55
-44
lines changed

3 files changed

+55
-44
lines changed

flake.lock

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

flake.nix

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,37 @@
33

44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6-
flake-utils.url = "github:numtide/flake-utils";
6+
flake-parts.url = "github:hercules-ci/flake-parts";
77
};
88

9-
outputs = { self, nixpkgs, flake-utils }:
10-
flake-utils.lib.eachDefaultSystem (system:
11-
let
12-
pkgs = nixpkgs.legacyPackages.${system};
13-
in
14-
{
15-
devShells.default = pkgs.mkShell {
16-
buildInputs = with pkgs; [
17-
pnpm_10
18-
];
9+
outputs =
10+
inputs@{ flake-parts, ... }:
11+
flake-parts.lib.mkFlake { inherit inputs; } {
12+
systems = [
13+
"x86_64-linux"
14+
"aarch64-linux"
15+
"aarch64-darwin"
16+
];
1917

20-
shellHook = ''
21-
echo "StackOne AI Node SDK development environment"
18+
perSystem =
19+
{ pkgs, ... }:
20+
{
21+
devShells.default = pkgs.mkShell {
22+
buildInputs = with pkgs; [
23+
pnpm_10
24+
nixfmt-rfc-style
25+
];
2226

23-
# Install dependencies only if node_modules/.pnpm/lock.yaml is older than pnpm-lock.yaml
24-
if [ ! -f node_modules/.pnpm/lock.yaml ] || [ pnpm-lock.yaml -nt node_modules/.pnpm/lock.yaml ]; then
25-
echo "📦 Installing dependencies..."
26-
pnpm install --frozen-lockfile
27-
fi
28-
'';
27+
shellHook = ''
28+
echo "StackOne AI Node SDK development environment"
29+
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+
};
2937
};
30-
}
31-
);
38+
};
3239
}

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)