From a217b502a21f48feb17bf3e93fd72c645cfbf356 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sun, 28 Jun 2026 02:34:10 -0400 Subject: [PATCH] nix: add flake tempalte --- README.md | 2 +- flake.nix | 21 +++++++++++----- templates/default/agent.nix | 33 ++++++++++++++++++++++++ templates/default/flake.nix | 50 +++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 templates/default/agent.nix create mode 100644 templates/default/flake.nix diff --git a/README.md b/README.md index 4756b29..86f0f58 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Prerequisites: - Nix with flakes enabled - Python 3.13+ and `uv` -- Linux with `bubblewrap` available for jailed execution +- Linux with `bubblewrap` available for jailed execution (`x86_64-linux` or `aarch64-linux`) - An OpenAI-compatible chat-completions endpoint Set an API key and ask the default agent a question: diff --git a/flake.nix b/flake.nix index 4d9cbf6..e6f7282 100644 --- a/flake.nix +++ b/flake.nix @@ -30,7 +30,6 @@ supportedSystems = [ "x86_64-linux" "aarch64-linux" - "aarch64-darwin" ]; inherit (nixpkgs) lib; eachSystem = lib.genAttrs supportedSystems; @@ -52,16 +51,14 @@ system: let pkgs = pkgsFor system; - packages = { }; # optional: add this flake's own derivations when capabilities need them in - agentsLib.mkAgents { inherit pkgs packages; } (import ./agent.nix { inherit pkgs agentModules; }) + agentsLib.mkAgents { inherit pkgs; } (import ./agent.nix { inherit pkgs agentModules; }) ); checks = eachSystem ( system: let pkgs = pkgsFor system; - packages = { }; moduleNames = [ "bash" "read" @@ -72,11 +69,11 @@ "grep" "web_fetch" ]; - resolvedCatalog = agentsLib.resolveCapabilities { inherit pkgs packages; } ( + resolvedCatalog = agentsLib.resolveCapabilities { inherit pkgs; } ( map (moduleName: agentModules.${moduleName}) moduleNames ); defaultManifest = - (agentsLib.mkAgents { inherit pkgs packages; } (import ./agent.nix { inherit pkgs agentModules; })) + (agentsLib.mkAgents { inherit pkgs; } (import ./agent.nix { inherit pkgs agentModules; })) .default.manifest; catalogCapabilityNames = lib.attrNames resolvedCatalog; expectedCapabilityNames = [ @@ -190,5 +187,17 @@ }; } ); + + templates.default = { + path = ./templates/default; + description = "Minimal Tartarus agent with core tools and a dev shell"; + welcomeText = '' + Your Tartarus agent is ready. + + nix develop + + Set TARTARUS_API_KEY (or OPENCODE_API_KEY) before running the agent. + ''; + }; }; } diff --git a/templates/default/agent.nix b/templates/default/agent.nix new file mode 100644 index 0000000..8f67873 --- /dev/null +++ b/templates/default/agent.nix @@ -0,0 +1,33 @@ +{ pkgs, agentModules }: + +{ + default = { + systemPrompt = '' + You are a careful coding agent running inside Tartarus. Use only the + tools you have been granted, and prefer the narrowest capability that + does the job. + ''; + + shell = with pkgs; [ bash coreutils ]; + + model = { + baseUrl = "https://opencode.ai/zen/v1"; + name = "glm-5.2"; + maxTokens = 32768; + sampling = { + temperature = 0.6; + }; + }; + + capabilities = with agentModules; [ + read + list + write + edit + glob + grep + bash + web_fetch + ]; + }; +} diff --git a/templates/default/flake.nix b/templates/default/flake.nix new file mode 100644 index 0000000..9e40a92 --- /dev/null +++ b/templates/default/flake.nix @@ -0,0 +1,50 @@ +{ + description = "Minimal Tartarus agent with core tools and a dev shell"; + + inputs = { + nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*"; + tartarus.url = "github:alyraffauf/tartarus"; + }; + + outputs = { nixpkgs, tartarus, self, ... }: + let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + ]; + forEachSystem = nixpkgs.lib.genAttrs supportedSystems; + in + { + agents = forEachSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + tartarus.lib.mkAgents { inherit pkgs; } ( + import ./agent.nix { + inherit pkgs; + agentModules = tartarus.agentModules; + } + ) + ); + + devShells = forEachSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + default = pkgs.mkShellNoCC { + packages = [ tartarus.packages.${system}.tartarus ]; + }; + } + ); + + packages = forEachSystem ( + system: + { + default = self.agents.${system}.default.bundle; + } + ); + }; +} -- 2.51.2