Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ vars, packages, overlays or fleet values. Every module is off until its
- `git add` new files before any `nix` command.
- `fmt`, then `check`. Both must pass before a change is done.
- After `nix flake update org-pkgs`, run `sync-locks` in the same commit.
- VM tests: `vm-test --list`, `vm-test <name>` (local KVM) or `vm-test <name> --remote` (remote builder); the exit code is the result, logs in `.vm-tests/<name>/`. See the `vm-tests` skill.
- VM tests: `vm-test --list`, `vm-test <name>` (local KVM) or `vm-test <name> --remote` (remote builder); the exit code is the result, logs in `.vm-tests/<name>/`. See the external-systems skill's `references/vm-tests.md`.

## Rules
- Load the `nix-style` skill before editing any `.nix` file.
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ e.g. `nixosModules.tailscale` or `homeModules.starship`.
(nixd's option source). `hostSpec.services.nix` trusts only `root`; add
users with `nix.settings.trusted-users`. Personal shell aliases go in the
consumer's `programs.bash.shellAliases`.
- **AI agents.** `homeModules.agents` (`homeSpec.agents`) gives claude,
pi, kimi and opencode the same skills, MCP servers, Nix workflow and
instructions; an agent differs only where it cannot take a setting
(opencode's GitHub OAuth, Claude Desktop Chat's local-only servers).
`instructions.text` (and `<agent>.instructions.text`) is added after
the machine context and the org ground rules (`groundRules.enable`,
from external-systems/skills); `instructions.mode = "replace"` puts
it in place of the built-in system prompt (pi and kimi `SYSTEM.md`, a
claude output style; opencode stays on `"append"`).
- **VSCodium.** `homeModules.vscodium` (`homeSpec.programs.vscodium`) is
VSCodium only. Everything past `enable` is per user:
`languages.{nix,go,python,rust,gleam,zig,web,yaml,shell,markdown}.enable`,
Expand Down
8 changes: 4 additions & 4 deletions devenv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,17 @@
"zen-browser": "zen-browser"
},
"locked": {
"lastModified": 1794680531,
"narHash": "sha256-nZyIl+U5yHeOS2aNmh7rl5Hmp62aZdPQhCixtC2nRMk=",
"lastModified": 1794710907,
"narHash": "sha256-kdDp4EUFxT8WXCEx93nZN8Xxb6T7sWg7vf8eYvG8utI=",
"owner": "external-systems",
"repo": "pkgs",
"rev": "8a04c686191637246ffd621d4c872a030e81cf73",
"rev": "2bacfc8371dd6988db44eaa9f52f707ad0b2399f",
"type": "github"
},
"original": {
"owner": "external-systems",
"repo": "pkgs",
"rev": "8a04c686191637246ffd621d4c872a030e81cf73",
"rev": "2bacfc8371dd6988db44eaa9f52f707ad0b2399f",
"type": "github"
}
},
Expand Down
2 changes: 1 addition & 1 deletion devenv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# pkgs ("attribute 'bash' missing").
inputs:
org-pkgs:
url: github:external-systems/pkgs/8a04c686191637246ffd621d4c872a030e81cf73
url: github:external-systems/pkgs/2bacfc8371dd6988db44eaa9f52f707ad0b2399f
nixpkgs:
follows: org-pkgs/nixpkgs
imports:
Expand Down
2 changes: 1 addition & 1 deletion flake-parts/homeModules/agents/_claude.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@

# The server names the module has ever written to ~/.claude.json:
# the bootstrap for the first sync, when no state file exists yet.
knownServers = ["artifacthub" "github" "headroom" "kubernetes" "nixos"];
knownServers = ["artifacthub" "github" "headroom" "kubernetes" "nixos" "varlock-docs"];
}
237 changes: 168 additions & 69 deletions flake-parts/homeModules/agents/agents.nix

Large diffs are not rendered by default.

30 changes: 6 additions & 24 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions tests/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,53 @@
assert expect (hm.home.activation ? kimiNixWorkflow) "no kimi config.toml merge";
pkgs.writeText "agents-wiring" "ok";

# Instructions reach every agent the same way: machine context, the
# org ground rules, the user's text, then the agent's own text;
# "replace" moves them into each agent's system-prompt spot
# (opencode has none and must stay on "append"). Remote MCP servers
# reach every agent too, and claude reads /tmp like opencode.
agents-instructions = let
with' = module:
(machine.extendModules {modules = [{home-manager.users.alice = module;}];}).config.home-manager.users.alice;
appended = with' {
homeSpec.agents = {
instructions.text = "Shared user text.";
claude.instructions.text = "Claude only.";
mcp.varlock-docs.enable = true;
};
};
replaced = with' {
homeSpec.agents = {
instructions.mode = "replace";
opencode.instructions.mode = "append";
};
};
noRules = with' {homeSpec.agents.groundRules.enable = false;};
opencodeReplace = with' {homeSpec.agents.instructions.mode = "replace";};
text = hm: name: hm.home.file.${name}.text;
json = hm: name: builtins.fromJSON (builtins.unsafeDiscardStringContext (text hm name));
rules = "external-systems ground rules";
expect = cond: msg: lib.assertMsg cond "agents-instructions: ${msg}";
in
assert expect (lib.all (f: lib.hasInfix rules f && lib.hasInfix "Shared user text." f) [
(text appended ".pi/agent/AGENTS.md")
(text appended ".kimi-code/AGENTS.md")
(text appended ".claude/CLAUDE.md")
appended.xdg.configFile."opencode/AGENTS.md".text
]) "an agent misses the ground rules or the shared text";
assert expect (lib.hasInfix "Claude only." (text appended ".claude/CLAUDE.md") && !(lib.hasInfix "Claude only." (text appended ".pi/agent/AGENTS.md"))) "claude's own text is not claude-only";
assert expect (!(lib.hasInfix rules (text noRules ".pi/agent/AGENTS.md"))) "groundRules.enable = false keeps the rules";
assert expect ((json appended ".kimi-code/mcp.json").mcpServers.varlock-docs.type == "http") "kimi has no remote varlock-docs";
assert expect ((json appended ".pi/agent/mcp.json").mcpServers.varlock-docs ? url) "pi has no remote varlock-docs";
assert expect (appended.programs.opencode.settings.mcp.servers.varlock-docs.type == "remote") "opencode has no remote varlock-docs";
assert expect (lib.hasInfix "varlock-docs" appended.home.activation.claudeMcpServers.data) "claude's ~/.claude.json sync lacks varlock-docs";
assert expect (lib.elem "/tmp" (json appended ".claude/settings.json").permissions.additionalDirectories) "claude cannot read /tmp";
assert expect (replaced.home.file ? ".pi/agent/SYSTEM.md" && !(replaced.home.file ? ".pi/agent/AGENTS.md")) "pi replace does not write SYSTEM.md alone";
assert expect (replaced.home.file ? ".kimi-code/SYSTEM.md" && !(replaced.home.file ? ".kimi-code/AGENTS.md")) "kimi replace does not write SYSTEM.md alone";
assert expect ((json replaced ".claude/settings.json").outputStyle == "home-manager" && lib.hasInfix rules (text replaced ".claude/output-styles/home-manager.md")) "claude replace does not select the output style";
assert expect (lib.any (a: !a.assertion && lib.hasInfix "opencode cannot replace" a.message) opencodeReplace.assertions) "opencode replace is not refused";
pkgs.writeText "agents-instructions" "ok";

# Each agent on its own: it writes exactly its own files, and still
# gets the shared machine context, MCP servers, skills and Nix
# workflow; the other three leave nothing behind.
Expand Down
Loading