Some checks failed
Update Nix Packages with nix-update / nix-update (push) Failing after 2m27s
156 lines
4.8 KiB
Nix
156 lines
4.8 KiB
Nix
# OpenCode development environment with AI coding rules
|
||
# This shell demonstrates the mkOpencodeRules library provided by this repository
|
||
# Usage: nix develop .#opencode
|
||
#
|
||
# To enable OpenCode rules, add the agents input to your flake:
|
||
# agents = {
|
||
# url = "git+https://code.m3ta.dev/m3tam3re/AGENTS";
|
||
# flake = false;
|
||
# };
|
||
{
|
||
pkgs,
|
||
lib ? pkgs.lib,
|
||
inputs ? null,
|
||
agents ? null,
|
||
}: let
|
||
# Import the opencode-rules library
|
||
m3taLib = import ../lib {lib = pkgs.lib;};
|
||
|
||
# Import custom packages
|
||
customPackages = import ../pkgs {inherit pkgs inputs;};
|
||
|
||
# Create rules configuration only if agents input is provided
|
||
# This demonstrates how to use mkOpencodeRules in a real project
|
||
rulesConfig = lib.optionalAttrs (agents != null) {
|
||
rules = m3taLib.opencode-rules.mkOpencodeRules {
|
||
# Pass the AGENTS repository path
|
||
inherit agents;
|
||
|
||
# Languages relevant to this repository
|
||
languages = ["python" "typescript" "nix"];
|
||
|
||
# Frameworks used in this repo
|
||
frameworks = ["n8n"];
|
||
|
||
# Standard concerns for development
|
||
concerns = [
|
||
"coding-style"
|
||
"naming"
|
||
"documentation"
|
||
"testing"
|
||
"git-workflow"
|
||
"project-structure"
|
||
];
|
||
};
|
||
};
|
||
in
|
||
pkgs.mkShell {
|
||
name = "opencode-dev";
|
||
|
||
# Development tools
|
||
buildInputs = with pkgs;
|
||
[
|
||
# OpenCode AI coding agent (if inputs are available)
|
||
]
|
||
++ lib.optionals (inputs != null)
|
||
[inputs.opencode.packages.${pkgs.system}.opencode]
|
||
++ [
|
||
# Task management for AI coding sessions
|
||
customPackages.td
|
||
|
||
# Companion tool for CLI agents (diffs, file trees, task management)
|
||
customPackages.sidecar
|
||
|
||
# Code analysis tools
|
||
customPackages.code2prompt
|
||
|
||
# Nix development tools (for this repo)
|
||
nil
|
||
alejandra
|
||
statix
|
||
deadnix
|
||
];
|
||
|
||
# Shell hook that sets up OpenCode rules
|
||
shellHook = ''
|
||
echo "🤖 OpenCode Development Environment"
|
||
echo ""
|
||
echo "This environment demonstrates the mkOpencodeRules library"
|
||
echo "provided by the m3ta-nixpkgs repository."
|
||
echo ""
|
||
|
||
${
|
||
if (agents != null)
|
||
then ''
|
||
# Execute the OpenCode rules shellHook
|
||
${rulesConfig.rules.shellHook}
|
||
|
||
echo "✅ OpenCode rules configured!"
|
||
''
|
||
else ''
|
||
echo "⚠️ OpenCode rules not configured"
|
||
echo ""
|
||
echo "To enable OpenCode rules, add the agents input to your flake.nix:"
|
||
echo ""
|
||
echo " inputs = {"
|
||
echo " m3ta-nixpkgs.url = \"git+https://code.m3ta.dev/m3tam3re/nixpkgs\";"
|
||
echo " agents = {"
|
||
echo " url = \"git+https://code.m3ta.dev/m3tam3re/AGENTS\";"
|
||
echo " flake = false;"
|
||
echo " };"
|
||
echo " };"
|
||
echo ""
|
||
echo "Then pass agents to the shell:"
|
||
echo " opencode = import ./opencode.nix { inherit pkgs inputs agents; };"
|
||
''
|
||
}
|
||
|
||
echo ""
|
||
echo "Available tools:"
|
||
echo " opencode - AI coding agent"
|
||
echo " td usage --new-session - View current tasks"
|
||
echo " sidecar - Companion tool (diffs, file trees, tasks)"
|
||
echo " code2prompt - Convert code to prompts"
|
||
echo ""
|
||
echo "Nix development tools:"
|
||
echo " nix flake check - Check flake validity"
|
||
echo " nix fmt . - Format Nix files"
|
||
echo " statix check . - Lint Nix files"
|
||
echo " deadnix . - Find dead code"
|
||
echo ""
|
||
${
|
||
if (agents == null)
|
||
then ''
|
||
echo "💡 Using mkOpencodeRules in your project:"
|
||
echo ""
|
||
echo "Add to your flake.nix:"
|
||
echo " inputs = {"
|
||
echo " m3ta-nixpkgs.url = \"git+https://code.m3ta.dev/m3tam3re/nixpkgs\";"
|
||
echo " agents = {"
|
||
echo " url = \"git+https://code.m3ta.dev/m3tam3re/AGENTS\";"
|
||
echo " flake = false;"
|
||
echo " };"
|
||
echo " };"
|
||
echo ""
|
||
echo " outputs = {self, nixpkgs, m3ta-nixpkgs, agents, ...}:"
|
||
echo " let"
|
||
echo " system = \"x86_64-linux\";"
|
||
echo " pkgs = nixpkgs.legacyPackages.''${system};"
|
||
echo " m3taLib = m3ta-nixpkgs.lib.''${system};"
|
||
echo " rules = m3taLib.opencode-rules.mkOpencodeRules {"
|
||
echo " inherit agents;"
|
||
echo " languages = [\"python\" \"typescript\"];"
|
||
echo " frameworks = [\"n8n\"];"
|
||
echo " };"
|
||
echo " in {"
|
||
echo " devShells.''${system}.default = pkgs.mkShell {"
|
||
echo " shellHook = rules.shellHook;"
|
||
echo " };"
|
||
echo " };"
|
||
''
|
||
else ""
|
||
}
|
||
echo ""
|
||
'';
|
||
}
|