From 047b60a6a83957d620dde350beaf931c614fbcb8 Mon Sep 17 00:00:00 2001
From: m3tm3re
Date: Wed, 22 Apr 2026 17:59:23 +0200
Subject: [PATCH] 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
---
AGENTS.md | 117 ++++++++++++++++++++++++++++++++++++
flake.lock | 27 +++++++--
flake.nix | 35 ++---------
home/features/coding/pi.nix | 33 ++++++++--
4 files changed, 171 insertions(+), 41 deletions(-)
diff --git a/AGENTS.md b/AGENTS.md
index 346fadb..69ede44 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -71,6 +71,123 @@ Personal NixOS configuration managing 6 hosts (4 servers, 2 desktops) using flak
- **master**: Bleeding edge
- **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: `: `
+
+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
```bash
# Build/deploy specific host
diff --git a/flake.lock b/flake.lock
index 35ac1ce..d907f7d 100644
--- a/flake.lock
+++ b/flake.lock
@@ -39,6 +39,22 @@
"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": {
"flake": false,
"locked": {
@@ -412,11 +428,11 @@
"treefmt-nix": "treefmt-nix"
},
"locked": {
- "lastModified": 1776784995,
- "narHash": "sha256-ikxb8cZGWHuZMs3xS471GVrpGA0xW1YFcIVOPTVkhBo=",
+ "lastModified": 1776870400,
+ "narHash": "sha256-PleMddBk0Vp2iVsNVgqmL00u1xX1cFx8FVYOEOur/1Q=",
"owner": "numtide",
"repo": "llm-agents.nix",
- "rev": "e3d40d2cd66a4f8052e4224ec027c6896a455847",
+ "rev": "bd0e8933483e6e1b33bd83c5e844926b33db0f75",
"type": "github"
},
"original": {
@@ -427,6 +443,7 @@
},
"m3ta-nixpkgs": {
"inputs": {
+ "agents": "agents_2",
"basecamp": "basecamp",
"nixpkgs": "nixpkgs_6",
"nixpkgs-master": "nixpkgs-master",
@@ -434,8 +451,8 @@
"openspec": "openspec"
},
"locked": {
- "lastModified": 1776787894,
- "narHash": "sha256-aDi7tWtiBdUBLhH4ULHZpcUTq3/w/Rad6dA/uLHu+7Q=",
+ "lastModified": 1776872602,
+ "narHash": "sha256-v1rGBLuanysy7z0BBgId1DYknIovLF5VI6xbT4abjTI=",
"path": "/home/m3tam3re/p/NIX/nixpkgs",
"type": "path"
},
diff --git a/flake.nix b/flake.nix
index 346c109..a8c7b12 100644
--- a/flake.nix
+++ b/flake.nix
@@ -178,7 +178,7 @@
config.allowUnfree = true; # Allow unfree packages in devShell
};
m3taLib = m3ta-nixpkgs.lib.x86_64-linux;
- rules = m3taLib.opencode-rules.mkOpencodeRules {
+ rules = m3taLib.coding-rules.mkCodingRules {
inherit agents;
languages = ["nix"];
};
@@ -189,37 +189,10 @@
nixd
openssh
agenix.packages.${system}.default
+ statix
+ deadnix
];
- inherit (rules) instructions;
- 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 "======================================"
- '';
+ inherit (rules) instructions shellHook;
};
});
};
diff --git a/home/features/coding/pi.nix b/home/features/coding/pi.nix
index 8285dba..9de9b26 100644
--- a/home/features/coding/pi.nix
+++ b/home/features/coding/pi.nix
@@ -4,8 +4,30 @@
agentsInput = inputs.agents;
modelOverrides = {
- chiron = "zai/glm-5.1";
- chiron-forge = "zai/glm-5.1";
+ chiron = "minimax/MiniMax-M2.7";
+ 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 = {
@@ -20,12 +42,13 @@
"npm:pi-powerline-footer"
"npm:pi-markdown-preview"
"npm:pi-gsd"
- "npm:pi-tool-view"
+ "npm:pi-tool-display"
"npm:pi-agent-browser-native"
+ "git:github.com/hk-vk/pi-connect"
];
- defaultProvider = "zai";
- defaultModel = "glm-5.1";
+ defaultProvider = "minimax";
+ defaultModel = "MiniMax-M2.7";
defaultThinkingLevel = "high";
};