Files
NixOsConfig/modules/ai/claude-code.nix
T
Claude af18420fd3 Switch to the dendritic flake-parts layout, with stubs for phase 2
flake.nix now only declares inputs and calls flake-parts with import-tree
over ./modules: every .nix file under modules/ is a flake-parts module.
Features are aspects (flake.modules.nixos.<name> and
flake.modules.homeManager.<name>); importing an aspect enables it, so the
my.* option modules and their enable flags are gone.

- Add the flake-parts glue: modules/flake/ (systems, shared meta data,
  host construction through configurations.nixos, overlays, packages,
  apps, dev shell, formatter, checks), modules/users/faumaray.nix
  (meta.owner) and modules/core/{nixpkgs,home-manager,install-facts}.nix.
  config.my is kept as one read-only derived option so install-system
  keeps working unchanged.
- Add the aspects that are already final: secrets, ssh, hyprland,
  wezterm, git, stylix, proxy-suite, gitea-runner and claude-code, and
  the desktop host (modules/hosts/desktop/{host,hardware,disks}.nix).
- Port the always-on basics to the `core` aspect (nix, boot, locale,
  networking, users), lanzaboote and plain systemd-boot to the
  `secure-boot` and `systemd-boot` aspects, and the installer ISO to
  modules/installer/iso.nix. Behaviour is unchanged; the time zone,
  default locale, XKB layouts and the firewall setting now live in
  modules/hosts/desktop/host.nix.
- Move the Lua files (Hyprland settings, binds, rules; Neovim init.lua)
  with git mv, byte-identical.
- Add bare stubs, marked STUB, for the aspects that the next phase
  ports: amd, rocm, gaming, vpn, docker, noctalia, audio, fonts, xdg,
  apps, shell and neovim. The host evaluates with them, but those
  features are not configured until they are ported.
- Remove lib/, overlays/, apps/, modules/nixos/, modules/home/,
  modules/installer/default.nix and hosts/desktop/{default,disks,home}.nix.
- flake.lock: add flake-parts, import-tree, stylix and serena with their
  transitive inputs (22 new nodes); every existing pin is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JZ16yf4acmaSiHq81vyQ6Z
2026-10-12 20:55:34 +00:00

108 lines
3.9 KiB
Nix

# Claude Code (pkgs.claude-code, unfree) for the owner, through home-manager's
# programs.claude-code, with:
# codememory MCP server: codebase-memory-mcp (DeusData), code knowledge graph (nixpkgs)
# serena MCP server: semantic code retrieval and editing (inputs.serena)
# rea MCP server and skill: Reverse Engineer Anything (npm rea-agents)
# caveman plugin: skills, commands, agents and hooks (JuliusBrussee/caveman)
# Everything is user scope (~/.claude). A repository's own .claude/settings.json
# still applies on top of it; nothing here sets a model, effort, permissions or
# hooks. MCP servers land in home-manager's generated plugin, so their tools
# are named mcp__plugin_hm_<server>__<tool>.
{ inputs, ... }:
{
flake.modules.homeManager.claude-code =
{
lib,
pkgs,
...
}:
let
serena = inputs.serena.packages.${pkgs.stdenv.hostPlatform.system}.serena;
# REA has no Nix package: the MCP server runs from npm through npx
# (pinned version, fetched on first start: not hermetic). Its skill comes
# from the same npm release. Knobs: reaVersion and the hash below.
reaVersion = "6.4.0";
reaPackage = pkgs.fetchzip {
url = "https://registry.npmjs.org/rea-agents/-/rea-agents-${reaVersion}.tgz";
hash = "sha256-aJTYn9CZchdwJLBMn9no4C2EGBO6XemsH3J0GU1DqWM=";
};
# `rea` on PATH and as the MCP command; npx needs node for the package's
# own `#!/usr/bin/env node` scripts.
rea = pkgs.writeShellApplication {
name = "rea";
runtimeInputs = [ pkgs.nodejs ];
text = ''exec npx --yes "rea-agents@${reaVersion}" "$@"'';
};
# Knobs: tag and hash.
caveman = pkgs.fetchFromGitHub {
owner = "JuliusBrussee";
repo = "caveman";
tag = "v3.2.0";
hash = "sha256-GfC8e+EGL7kotZQfZ9kD7ZEWJfhmXujHOHpMxeU3bEo=";
};
in
{
programs.claude-code = {
enable = true;
# Claude Code also writes ~/.claude/settings.json itself; merge the
# declared keys into a writable file on every switch instead of
# replacing it with a read-only link.
mutableSettings = true;
# Serena (Python) can take longer than the default MCP start timeout.
settings.env.MCP_TIMEOUT = "60000";
mcpServers = {
# To use another code-memory server, replace this one entry.
codememory = {
command = lib.getExe pkgs.codebase-memory-mcp;
args = [ ];
};
serena = {
command = lib.getExe serena;
args = [
"start-mcp-server"
"--context"
"claude-code"
"--project-from-cwd"
"--open-web-dashboard"
"false"
];
};
rea = {
command = lib.getExe rea;
args = [ "mcp" ];
};
};
skills.reverse-engineer-anything = "${reaPackage}/skills/reverse-engineer-anything";
# Loaded as a personal plugin (Claude Code >= 2.1.157).
plugins.caveman = caveman;
};
# The CLIs themselves; caveman's hooks need `node` on PATH (they exit
# silently without it).
home.packages = [
pkgs.codebase-memory-mcp
serena
rea
pkgs.nodejs
];
# caveman switches every new session into its terse style unless its
# default mode says otherwise. Start with it off (turn it on per session
# with /caveman), so agents in repositories like this one keep their
# normal reports. Written once; caveman may change it later.
home.activation.cavemanDefaultMode = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
if [ ! -e "$HOME/.config/caveman/config.json" ]; then
run mkdir -p "$HOME/.config/caveman"
run sh -c 'echo "{\"defaultMode\": \"off\"}" > "$HOME/.config/caveman/config.json"'
fi
'';
};
}