feat: nb add claude code
This commit is contained in:
32
hosts/nb/modules/development/claude-code.nix
Normal file
32
hosts/nb/modules/development/claude-code.nix
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
user = "dominik";
|
||||||
|
home = "/home/${user}";
|
||||||
|
npmPrefix = "${home}/.npm-global";
|
||||||
|
node = pkgs.nodejs; # or pkgs.nodejs_20
|
||||||
|
in {
|
||||||
|
home-manager.users.dominik = { config, lib, pkgs, ... }: {
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
];
|
||||||
|
|
||||||
|
home.activation.installClaudeCode = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||||
|
export PATH=${node}/bin:${pkgs.gnutar}/bin:${pkgs.gzip}/bin:${pkgs.unzip}/bin:${pkgs.curl}/bin:$PATH
|
||||||
|
mkdir -p ${npmPrefix}
|
||||||
|
if [ ! -x "${npmPrefix}/bin/claude" ]; then
|
||||||
|
echo "Installing @anthropic-ai/claude-code globally..."
|
||||||
|
# --global uses prefix from ~/.npmrc; PATH has node for postinstall
|
||||||
|
${node}/bin/npm install -g @anthropic-ai/claude-code
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
|
home.activation.addChromeDevtoolsMCP = lib.hm.dag.entryAfter [ "installClaudeCli" ] ''
|
||||||
|
# Add via STDIO transport: Claude spawns `npx -y chrome-devtools-mcp ...`
|
||||||
|
# Browser must be running with remote debugging on 127.0.0.1:9222.
|
||||||
|
if ${config.home.homeDirectory}/.nix-profile/bin/claude mcp add --help >/dev/null 2>&1; then
|
||||||
|
${config.home.homeDirectory}/.nix-profile/bin/claude mcp add --scope user chrome-devtools \
|
||||||
|
-- npx -y chrome-devtools-mcp --browserUrl=http://127.0.0.1:9222 || true
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user