mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-08 18:11:05 +01:00
claude-code: refactor wrapper to use append-flags
Alternative approach suggested in https://github.com/nix-community/home-manager/pull/8290#discussion_r2593114782 Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
1a99a515a1
commit
519828bf1c
2 changed files with 14 additions and 14 deletions
|
|
@ -345,23 +345,24 @@ in
|
||||||
|
|
||||||
programs.claude-code.finalPackage =
|
programs.claude-code.finalPackage =
|
||||||
let
|
let
|
||||||
mcpConfigFile = jsonFormat.generate "claude-code-mcp-config.json" {
|
makeWrapperArgs = lib.flatten (
|
||||||
inherit (cfg) mcpServers;
|
lib.filter (x: x != [ ]) [
|
||||||
};
|
(lib.optional (cfg.mcpServers != { }) [
|
||||||
|
"--append-flags"
|
||||||
|
"--mcp-config ${jsonFormat.generate "claude-code-mcp-config.json" { inherit (cfg) mcpServers; }}"
|
||||||
|
])
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
needsWrapper = cfg.mcpServers != { };
|
hasWrapperArgs = makeWrapperArgs != [ ];
|
||||||
|
|
||||||
wrapperScript = pkgs.writeShellScriptBin "claude" ''
|
|
||||||
exec "${lib.getExe cfg.package}" "$@" --mcp-config "${mcpConfigFile}"
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
if needsWrapper then
|
if hasWrapperArgs then
|
||||||
pkgs.symlinkJoin {
|
pkgs.symlinkJoin {
|
||||||
name = "claude-code";
|
name = "claude-code";
|
||||||
paths = [ cfg.package ];
|
paths = [ cfg.package ];
|
||||||
|
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||||
postBuild = ''
|
postBuild = ''
|
||||||
rm $out/bin/claude
|
wrapProgram $out/bin/claude ${lib.escapeShellArgs makeWrapperArgs}
|
||||||
ln -s ${wrapperScript}/bin/claude $out/bin/claude
|
|
||||||
'';
|
'';
|
||||||
inherit (cfg.package) meta;
|
inherit (cfg.package) meta;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
#!/nix/store/00000000000000000000000000000000-bash/bin/bash
|
#! /nix/store/00000000000000000000000000000000-bash/bin/bash -e
|
||||||
exec "/nix/store/00000000000000000000000000000000-claude-code/bin/claude-code" "$@" --mcp-config "/nix/store/00000000000000000000000000000000-claude-code-mcp-config.json"
|
exec -a "$0" "/nix/store/00000000000000000000000000000000-claude-code/bin/.claude-wrapped" "$@" --mcp-config /nix/store/00000000000000000000000000000000-claude-code-mcp-config.json
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue