mirror of
https://github.com/srid/nixos-config.git
synced 2026-01-14 19:25:18 +08:00
99 lines
2.7 KiB
Nix
99 lines
2.7 KiB
Nix
{ flake, pkgs, lib, ... }:
|
|
let
|
|
subagentsDir = ./subagents;
|
|
agents = lib.mapAttrs'
|
|
(fileName: _:
|
|
lib.nameValuePair
|
|
(lib.removeSuffix ".md" fileName)
|
|
(builtins.readFile (subagentsDir + "/${fileName}"))
|
|
)
|
|
(builtins.readDir subagentsDir);
|
|
|
|
commandsDir = ./commands;
|
|
commands = lib.mapAttrs'
|
|
(fileName: _:
|
|
lib.nameValuePair
|
|
(lib.removeSuffix ".md" fileName)
|
|
(builtins.readFile (commandsDir + "/${fileName}"))
|
|
)
|
|
(builtins.readDir commandsDir);
|
|
|
|
skillsDir = ./skills;
|
|
skillDirs = lib.filterAttrs (_: type: type == "directory") (builtins.readDir skillsDir);
|
|
|
|
# Process skill: if it has default.nix, build and substitute; otherwise use as-is
|
|
processSkill = skillName:
|
|
let
|
|
skillPath = skillsDir + "/${skillName}";
|
|
hasDefaultNix = builtins.pathExists (skillPath + "/default.nix");
|
|
in
|
|
if hasDefaultNix then
|
|
let
|
|
skillPkg = pkgs.callPackage skillPath { };
|
|
in
|
|
pkgs.runCommand "${skillName}-skill" { } ''
|
|
mkdir -p $out
|
|
substitute ${skillPath}/SKILL.md $out/SKILL.md \
|
|
--replace-fail '@${skillName}@' '${skillPkg}/bin/${skillName}'
|
|
''
|
|
else
|
|
skillPath;
|
|
in
|
|
{
|
|
# Packages often used by Claude Code CLI.
|
|
home.packages = with pkgs; [
|
|
tree
|
|
];
|
|
|
|
# Link skill directories to ~/.claude/skills/
|
|
# (home-manager module doesn't support skills yet, so we link manually)
|
|
home.file = lib.mapAttrs'
|
|
(skillName: _:
|
|
lib.nameValuePair ".claude/skills/${skillName}" {
|
|
source = processSkill skillName;
|
|
recursive = true;
|
|
}
|
|
)
|
|
skillDirs;
|
|
programs.claude-code = {
|
|
enable = true;
|
|
|
|
# Use sandboxed version on Linux, plain version on macOS
|
|
package =
|
|
if pkgs.stdenv.isLinux
|
|
then flake.inputs.self.packages.${pkgs.system}.claude # see claude-sandboxed.nix
|
|
else pkgs.claude-code;
|
|
|
|
# Basic settings for Claude Code
|
|
settings = {
|
|
# theme = "dark";
|
|
permissions = {
|
|
defaultMode = "bypassPermissions";
|
|
};
|
|
# Disable Claude from adding itself as co-author to commits
|
|
includeCoAuthoredBy = false;
|
|
};
|
|
|
|
# System prompt / memory
|
|
memory.text = builtins.readFile ./memory.md;
|
|
|
|
# Automatically discovered commands from commands/ directory
|
|
commands = commands;
|
|
|
|
# Automatically discovered agents from subagents/ directory
|
|
agents = agents;
|
|
|
|
# MCP servers configuration
|
|
# Works well without Nix; so be it.
|
|
mcpServers = {
|
|
"nixos-mcp" = {
|
|
command = "uvx";
|
|
args = [ "mcp-nixos" ];
|
|
};
|
|
"chrome-devtools" = {
|
|
command = "npx";
|
|
args = [ "chrome-devtools-mcp@latest" ];
|
|
};
|
|
};
|
|
};
|
|
}
|