Skip to content

Commit 4ba462c

Browse files
ryanbas21claude
andcommitted
feat: optimize flake with corepack, auto-install, and formatter
- Replace flake-utils with lightweight nix-systems/default - Swap Nix-provided pnpm for corepack (respects packageManager pin) - Auto-install deps when node_modules is missing or stale - Add nix fmt via nixfmt - Gitignore .corepack/ directory Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1102e5d commit 4ba462c

3 files changed

Lines changed: 39 additions & 42 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ elm-stuff/
1111
packged/
1212
out-tsc/
1313
.direnv/
14+
.corepack/

flake.lock

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

flake.nix

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,48 @@
33

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

99
outputs =
1010
{
1111
nixpkgs,
12-
flake-utils,
12+
systems,
1313
...
1414
}:
15-
flake-utils.lib.eachDefaultSystem (
16-
system:
17-
let
18-
pkgs = nixpkgs.legacyPackages.${system};
19-
in
20-
{
21-
devShells.default = pkgs.mkShell {
22-
packages = with pkgs; [
23-
nodejs_24
24-
pnpm
25-
lefthook
26-
];
15+
let
16+
eachSystem = nixpkgs.lib.genAttrs (import systems);
17+
in
18+
{
19+
devShells = eachSystem (
20+
system:
21+
let
22+
pkgs = nixpkgs.legacyPackages.${system};
23+
in
24+
{
25+
default = pkgs.mkShell {
26+
packages = with pkgs; [
27+
nodejs_24
28+
corepack
29+
lefthook
30+
];
31+
32+
shellHook = ''
33+
corepack enable --install-directory "$PWD/.corepack" >/dev/null 2>&1
34+
export PATH="$PWD/.corepack:$PATH"
35+
36+
if [ ! -d node_modules ]; then
37+
echo "node_modules missing — running pnpm install..."
38+
pnpm install
39+
elif [ pnpm-lock.yaml -nt node_modules ]; then
40+
echo "pnpm-lock.yaml is newer than node_modules — running pnpm install..."
41+
pnpm install
42+
fi
43+
'';
44+
};
45+
}
46+
);
2747

28-
shellHook = ''
29-
echo "wolfcola-devtools dev shell"
30-
echo " node $(node --version)"
31-
echo " pnpm $(pnpm --version)"
32-
'';
33-
};
34-
}
35-
);
48+
formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt);
49+
};
3650
}

0 commit comments

Comments
 (0)