Skip to content

Commit 86bf01d

Browse files
authored
perf(ci): use nix profile install instead of nix develop (#295)
* ci(nix): use nix profile install instead of nix develop - Replace nix develop --command with direct command execution - Add tools input to setup-nix action for per-job tool selection - Install only required tools per job (e.g., gitleaks job only installs gitleaks) - Remove cache-nix-action as nixpkgs binary cache handles caching - This should reduce CI setup time by avoiding devShell evaluation * fix(ci): skip pnpm install for gitleaks job gitleaks job only needs gitleaks binary, not node dependencies * perf(ci): use --inputs-from . for nixpkgs resolution Use flake.lock pinned nixpkgs revision to benefit from evaluation caching
1 parent 4afbb83 commit 86bf01d

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed
Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
name: 'Setup Nix'
22
description: 'Install Nix and configure cache'
3+
inputs:
4+
tools:
5+
description: 'Space-separated list of nixpkgs packages to install (e.g., "nodejs_24 pnpm_10 oxlint")'
6+
required: false
7+
default: 'nodejs_24 pnpm_10'
8+
skip-pnpm-install:
9+
description: 'Skip pnpm install step (useful for jobs that do not need node dependencies)'
10+
required: false
11+
default: 'false'
312
runs:
413
using: 'composite'
514
steps:
@@ -8,11 +17,17 @@ runs:
817
with:
918
github_access_token: ${{ github.token }}
1019

11-
- name: Cache Nix store
12-
uses: nix-community/cache-nix-action@b426b118b6dc86d6952988d396aa7c6b09776d08 # v7.0.0
13-
with:
14-
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', 'flake.lock', 'pnpm-lock.yaml') }}
20+
- name: Install tools from nixpkgs
21+
shell: bash
22+
run: |
23+
tools="${{ inputs.tools }}"
24+
packages=""
25+
for tool in $tools; do
26+
packages="$packages nixpkgs#$tool"
27+
done
28+
nix profile install --inputs-from . $packages
1529
16-
- name: Load Nix development environment
30+
- name: Install pnpm dependencies
31+
if: inputs.skip-pnpm-install != 'true'
1732
shell: bash
18-
run: nix develop --command true
33+
run: pnpm install --frozen-lockfile

.github/workflows/ci.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ jobs:
2626

2727
- name: Setup Nix
2828
uses: ./.github/actions/setup-nix
29+
with:
30+
tools: gitleaks
31+
skip-pnpm-install: 'true'
2932

3033
- name: Run Gitleaks
31-
run: nix develop --command gitleaks detect --source . --config .gitleaks.toml
34+
run: gitleaks detect --source . --config .gitleaks.toml
3235

3336
lint:
3437
runs-on: ubuntu-latest
@@ -37,8 +40,10 @@ jobs:
3740
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
3841
- name: Setup Nix
3942
uses: ./.github/actions/setup-nix
43+
with:
44+
tools: nodejs_24 pnpm_10 oxlint oxfmt similarity nixfmt tsgolint
4045
- name: Run Lint
41-
run: nix develop --command pnpm run lint
46+
run: pnpm run lint
4247

4348
build-and-test:
4449
runs-on: ubuntu-latest
@@ -50,10 +55,10 @@ jobs:
5055
uses: ./.github/actions/setup-nix
5156

5257
- name: Run Build
53-
run: nix develop --command pnpm run build
58+
run: pnpm run build
5459

5560
- name: Run Tests
56-
run: nix develop --command pnpm test
61+
run: pnpm test
5762

5863
coverage:
5964
runs-on: ubuntu-latest
@@ -64,7 +69,7 @@ jobs:
6469
- name: Setup Nix
6570
uses: ./.github/actions/setup-nix
6671
- name: Run Tests with Coverage
67-
run: nix develop --command pnpm run coverage
72+
run: pnpm run coverage
6873
- name: Create Coverage Badge
6974
uses: jaywcjlove/coverage-badges-cli@4e8975aa2628e3329126e7eee36724d07ed86fda # v2.2.0
7075
with:

0 commit comments

Comments
 (0)