refactor: update Pi agent configuration and devShell

- Switch model provider from zai/glm-5.1 to minimax/MiniMax-M2.7
- Add coding rules for Nix language and standard concerns
- Add linting tools (statix, deadnix) to devShell
- Simplify devShell configuration
- Update AGENTS.md project rules
This commit is contained in:
m3tm3re
2026-04-22 17:59:23 +02:00
parent 382b4c8c98
commit 047b60a6a8
4 changed files with 171 additions and 41 deletions

117
AGENTS.md
View File

@@ -71,6 +71,123 @@ Personal NixOS configuration managing 6 hosts (4 servers, 2 desktops) using flak
- **master**: Bleeding edge - **master**: Bleeding edge
- **m3ta-nixpkgs**: Custom local overlay at `path:/home/m3tam3re/p/nix/nixpkgs` - **m3ta-nixpkgs**: Custom local overlay at `path:/home/m3tam3re/p/nix/nixpkgs`
## CODING RULES
This project uses coding rules from the AGENTS repository (`inputs.agents`) plus project-specific conventions.
### Standard Rules (AGENTS repo)
| Rule | Source | Purpose |
|------|--------|---------|
| `languages/nix.md` | AGENTS/rules/ | Nix language conventions, flake patterns |
| `concerns/coding-style.md` | AGENTS/rules/ | General coding principles |
| `concerns/naming.md` | AGENTS/rules/ | Naming conventions per language |
| `concerns/documentation.md` | AGENTS/rules/ | Documentation standards |
| `concerns/testing.md` | AGENTS/rules/ | Testing guidelines |
| `concerns/git-workflow.md` | AGENTS/rules/ | Commit message format, branch naming |
| `concerns/project-structure.md` | AGENTS/rules/ | Project layout conventions |
### NixOS-Config Specific Rules
#### Project Structure
```
nixos-config/
├── flake.nix # Entry point
├── hosts/ # Host-specific NixOS configs
│ ├── common/ # Shared: ports, users, base config
│ ├── m3-atlas/ # Server with Traefik hub
│ ├── m3-helios/ # AdGuard DNS
│ ├── m3-ares/ # Desktop (NVIDIA)
│ └── m3-kratos/ # Desktop (AMD)
├── home/ # Home-manager configs
│ ├── common/ # Shared home config
│ ├── features/ # Feature modules (cli, desktop, coding)
│ └── m3tam3re/ # User-specific configs
├── modules/ # Custom NixOS/HM modules
├── overlays/ # Package overlays
├── pkgs/ # Custom packages
└── secrets/ # Agenix encrypted secrets
```
#### Naming Conventions
| Type | Convention | Example |
|------|------------|---------|
| Hosts | mythological-names | `m3-atlas`, `m3-helios` |
| Files | hyphen-case | `my-service.nix` |
| Variables | camelCase | `portHelpers`, `serviceConfig` |
| Options | m3ta.* | `config.m3ta.ports.get` |
| Packages | lowercase-hyphen | `hyprpaper-random` |
#### Nix Module Pattern
```nix
{ config, lib, pkgs, ... }:
with lib; let
cfg = config.m3ta.myModule;
in {
options.m3ta.myModule = {
enable = mkEnableOption "my module";
};
config = mkIf cfg.enable {
# Configuration here
};
}
```
#### Anti-Patterns (Never Do)
| Don't | Do Instead |
|-------|------------|
| Hardcode ports | `config.m3ta.ports.get "service"` |
| Skip secrets.nix update | Add keys first, then `agenix -e` |
| Containers outside web network | `--network=web --ip=10.89.0.N` |
| Skip Traefik for public services | Configure dynamic config |
| Bypass extraServices flags | Use feature flags properly |
| Use `fetchTarball` | Use flake inputs |
| Use `with pkgs;` in modules | Explicit `pkgs.package` |
### Formatting & Linting
```bash
# Format (alejandra)
nix fmt
# Lint (statix, deadnix - only in dev shell)
nix develop
statix check .
deadnix .
# Validate flake
nix flake check
```
### Commit Conventions
Format: `<type>: <brief description>`
Types: `feat`, `fix`, `docs`, `style`, `refactor`, `chore`
Examples:
- `feat: add new host m3-hermes`
- `fix: resolve port conflict in mem0 module`
- `docs: update AGENTS.md with new service`
- `style: format nix files`
- `refactor: simplify port management`
- `chore: update nixpkgs inputs`
### Tools in Dev Shell
| Tool | Purpose |
|------|---------|
| `alejandra` | Nix code formatter |
| `nixd` | Nix language server |
| `statix` | Nix linter |
| `deadnix` | Find dead code |
| `agenix` | Secret management |
## COMMANDS ## COMMANDS
```bash ```bash
# Build/deploy specific host # Build/deploy specific host

27
flake.lock generated
View File

@@ -39,6 +39,22 @@
"url": "https://code.m3ta.dev/m3tam3re/AGENTS" "url": "https://code.m3ta.dev/m3tam3re/AGENTS"
} }
}, },
"agents_2": {
"flake": false,
"locked": {
"lastModified": 1776092721,
"narHash": "sha256-avV4Snqp0K57I9s8D61+GHlg9DYZFSIvjaS4d4RYpG8=",
"ref": "refs/heads/master",
"rev": "0ad41acb03eee0e22cba611b2171a3d3ee30cb10",
"revCount": 72,
"type": "git",
"url": "https://code.m3ta.dev/m3tam3re/AGENTS"
},
"original": {
"type": "git",
"url": "https://code.m3ta.dev/m3tam3re/AGENTS"
}
},
"base16-schemes": { "base16-schemes": {
"flake": false, "flake": false,
"locked": { "locked": {
@@ -412,11 +428,11 @@
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
}, },
"locked": { "locked": {
"lastModified": 1776784995, "lastModified": 1776870400,
"narHash": "sha256-ikxb8cZGWHuZMs3xS471GVrpGA0xW1YFcIVOPTVkhBo=", "narHash": "sha256-PleMddBk0Vp2iVsNVgqmL00u1xX1cFx8FVYOEOur/1Q=",
"owner": "numtide", "owner": "numtide",
"repo": "llm-agents.nix", "repo": "llm-agents.nix",
"rev": "e3d40d2cd66a4f8052e4224ec027c6896a455847", "rev": "bd0e8933483e6e1b33bd83c5e844926b33db0f75",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -427,6 +443,7 @@
}, },
"m3ta-nixpkgs": { "m3ta-nixpkgs": {
"inputs": { "inputs": {
"agents": "agents_2",
"basecamp": "basecamp", "basecamp": "basecamp",
"nixpkgs": "nixpkgs_6", "nixpkgs": "nixpkgs_6",
"nixpkgs-master": "nixpkgs-master", "nixpkgs-master": "nixpkgs-master",
@@ -434,8 +451,8 @@
"openspec": "openspec" "openspec": "openspec"
}, },
"locked": { "locked": {
"lastModified": 1776787894, "lastModified": 1776872602,
"narHash": "sha256-aDi7tWtiBdUBLhH4ULHZpcUTq3/w/Rad6dA/uLHu+7Q=", "narHash": "sha256-v1rGBLuanysy7z0BBgId1DYknIovLF5VI6xbT4abjTI=",
"path": "/home/m3tam3re/p/NIX/nixpkgs", "path": "/home/m3tam3re/p/NIX/nixpkgs",
"type": "path" "type": "path"
}, },

View File

@@ -178,7 +178,7 @@
config.allowUnfree = true; # Allow unfree packages in devShell config.allowUnfree = true; # Allow unfree packages in devShell
}; };
m3taLib = m3ta-nixpkgs.lib.x86_64-linux; m3taLib = m3ta-nixpkgs.lib.x86_64-linux;
rules = m3taLib.opencode-rules.mkOpencodeRules { rules = m3taLib.coding-rules.mkCodingRules {
inherit agents; inherit agents;
languages = ["nix"]; languages = ["nix"];
}; };
@@ -189,37 +189,10 @@
nixd nixd
openssh openssh
agenix.packages.${system}.default agenix.packages.${system}.default
statix
deadnix
]; ];
inherit (rules) instructions; inherit (rules) instructions shellHook;
shellHook = ''
${rules.shellHook}
echo "======================================"
echo "🧑🚀 Nix Development Shell with Opencode Rules"
echo "======================================"
echo ""
echo "Active rules:"
echo " - Nix language conventions"
echo " - Coding-style best practices"
echo " - Naming conventions"
echo " - Documentation standards"
echo " - Testing guidelines"
echo " - Git workflow patterns"
echo " - Project structure guidelines"
echo ""
echo "Generated files:"
echo " - .opencode-rules/ (symlink to AGENTS repo)"
echo " - opencode.json (configuration file)"
echo ""
echo "Useful commands:"
echo " - cat opencode.json View rules configuration"
echo " - ls .opencode-rules/ Browse available rules"
echo " - nix develop Re-enter this shell"
echo ""
echo "Remember to add to .gitignore:"
echo " .opencode-rules"
echo " opencode.json"
echo "======================================"
'';
}; };
}); });
}; };

View File

@@ -4,8 +4,30 @@
agentsInput = inputs.agents; agentsInput = inputs.agents;
modelOverrides = { modelOverrides = {
chiron = "zai/glm-5.1"; chiron = "minimax/MiniMax-M2.7";
chiron-forge = "zai/glm-5.1"; chiron-forge = "minimax/MiniMax-M2.7";
};
# Coding rules for Pi agent
# Rules sourced from AGENTS repo
codingRules = {
# Language-specific rules
languages = [
"nix" # Nix language conventions
];
# Standard concerns from AGENTS repo
concerns = [
"coding-style" # General coding principles
"naming" # Naming conventions (camelCase, snake_case, etc.)
"documentation" # Documentation standards
"testing" # Testing guidelines (Arrange-Act-Assert)
"git-workflow" # Conventional commits, branch naming
"project-structure" # Project layout conventions
];
# No framework-specific rules for NixOS config
frameworks = [];
}; };
settings = { settings = {
@@ -20,12 +42,13 @@
"npm:pi-powerline-footer" "npm:pi-powerline-footer"
"npm:pi-markdown-preview" "npm:pi-markdown-preview"
"npm:pi-gsd" "npm:pi-gsd"
"npm:pi-tool-view" "npm:pi-tool-display"
"npm:pi-agent-browser-native" "npm:pi-agent-browser-native"
"git:github.com/hk-vk/pi-connect"
]; ];
defaultProvider = "zai"; defaultProvider = "minimax";
defaultModel = "glm-5.1"; defaultModel = "MiniMax-M2.7";
defaultThinkingLevel = "high"; defaultThinkingLevel = "high";
}; };