Skip to content

Commit b10c164

Browse files
authored
docs(rules): add nix-workflow rule (#106)
* docs(rules): add nix-workflow rule for development and CI guidance - Add .claude/rules/nix-workflow.md with guidance on: - Using flake.nix with flake-parts for dev environment - Adding tools to buildInputs - Treefmt and git-hooks configuration - CI workflow with setup-nix action - Recommended build flags (--print-build-logs --show-trace) - Update CLAUDE.md to include nix-workflow in available rules table Based on stackone-ai-node's nix-workflow.md, adapted for Python SDK with flake-parts, treefmt-nix, and git-hooks.nix specifics. * docs(rules): remove build flags section from nix-workflow These flags are only needed for debugging and slow down normal builds.
1 parent fda681f commit b10c164

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

.claude/rules/nix-workflow.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Nix Workflow
2+
3+
This rule provides guidance on Nix usage in the StackOne AI Python SDK.
4+
5+
## Development Environment
6+
7+
The project uses `flake.nix` with flake-parts to define the development environment. Enter it with `nix develop`.
8+
9+
### Adding Development Tools
10+
11+
To add a new tool to the development environment, add it to `buildInputs` in `flake.nix`:
12+
13+
```nix
14+
devShells.default = pkgs.mkShellNoCC {
15+
buildInputs = with pkgs; [
16+
uv
17+
ty
18+
just
19+
nixfmt-rfc-style
20+
21+
# your new tool here
22+
new-tool
23+
];
24+
};
25+
```
26+
27+
### Treefmt and Git Hooks
28+
29+
The flake includes:
30+
31+
- **treefmt-nix**: Unified formatting (nixfmt, ruff, oxfmt)
32+
- **git-hooks.nix**: Pre-commit hooks (gitleaks, treefmt, ty)
33+
34+
These are automatically installed when entering the dev shell.
35+
36+
## CI Workflow
37+
38+
CI uses `nix profile install` via the `.github/actions/setup-nix/action.yaml` composite action.
39+
40+
### Adding Tools to CI Jobs
41+
42+
Specify tools in the `tools` input of the setup-nix action:
43+
44+
```yaml
45+
- name: Setup Nix
46+
uses: ./.github/actions/setup-nix
47+
with:
48+
tools: uv ty just bun pnpm_10
49+
```
50+
51+
The action installs packages using:
52+
53+
```bash
54+
nix profile install --inputs-from . nixpkgs#tool1 nixpkgs#tool2
55+
```
56+
57+
### CI Tool Configuration
58+
59+
- **Default tools**: `uv ty just` (defined in action.yaml)
60+
- **Skip uv sync**: Set `skip-uv-sync: 'true'` for jobs that don't need Python dependencies
61+
62+
### Example: Adding a New Tool to CI Job
63+
64+
```yaml
65+
ci:
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Checkout repository
69+
uses: actions/checkout@v4
70+
with:
71+
submodules: true
72+
- name: Setup Nix
73+
uses: ./.github/actions/setup-nix
74+
with:
75+
tools: uv ty just new-tool
76+
- name: Run Lint
77+
run: just lint
78+
```
79+
80+
## Notes
81+
82+
- The project uses flake-parts for modular flake configuration
83+
- Git submodules are initialised automatically in dev shell and CI
84+
- MCP mock server dependencies (pnpm) are installed for testing

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
1515
| **git-workflow** | All files | Commit conventions, branch strategy, PR guidelines |
1616
| **development-workflow** | All files | Code style, file naming, project conventions |
1717
| **release-please-standards** | All files | Release versioning with release-please |
18+
| **nix-workflow** | All files | Nix development environment and CI configuration |
1819
| **no-relative-imports** | `**/*.py` | Enforce absolute imports in Python files |
1920
| **package-installation** | `**/pyproject.toml` | UV package management standards |
2021
| **uv-scripts** | `scripts/**/*.py` | Utility script standards with UV |

0 commit comments

Comments
 (0)