mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-31 04:04:32 +00:00
claude-code: add module
This commit is contained in:
parent
2d057cd9d4
commit
3fed4112c4
5 changed files with 96 additions and 0 deletions
|
@ -81,6 +81,7 @@ let
|
|||
./programs/cava.nix
|
||||
./programs/cavalier.nix
|
||||
./programs/chromium.nix
|
||||
./programs/claude-code.nix
|
||||
./programs/cmus.nix
|
||||
./programs/command-not-found/command-not-found.nix
|
||||
./programs/comodoro.nix
|
||||
|
|
75
modules/programs/claude-code.nix
Normal file
75
modules/programs/claude-code.nix
Normal file
|
@ -0,0 +1,75 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf mkOption types;
|
||||
cfg = config.programs.claude-code;
|
||||
in {
|
||||
meta.maintainers = with lib.maintainers; [ malo ];
|
||||
|
||||
options.programs.claude-code = {
|
||||
enable = lib.mkEnableOption "Claude Code CLI";
|
||||
|
||||
package = lib.mkPackageOption pkgs "claude-code" { };
|
||||
|
||||
disableAutoUpdate = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to disable the automatic update check on startup.
|
||||
This is recommended when using home-manager to manage {command}`claude`.
|
||||
'';
|
||||
};
|
||||
|
||||
enableOptionalDependencies = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to install the optional dependencies for {command}`claude`.
|
||||
This includes:
|
||||
- {command}`git` (for git operations)
|
||||
- {command}`rg` (for code search)
|
||||
- {command}`gh` (GitHub CLI, for GitHub operations)
|
||||
- {command}`glab` (GitLab CLI, for GitLab operations)
|
||||
'';
|
||||
};
|
||||
|
||||
withGitHubCLI = mkOption {
|
||||
type = types.bool;
|
||||
default = cfg.enableOptionalDependencies;
|
||||
description = ''
|
||||
Whether to enable GitHub CLI ({command}`gh`) as a dependency.
|
||||
This is useful if you work with GitHub repositories.
|
||||
|
||||
Defaults to the value of {option}`programs.claude-code.enableOptionalDependencies`.
|
||||
'';
|
||||
};
|
||||
|
||||
withGitLabCLI = mkOption {
|
||||
type = types.bool;
|
||||
default = cfg.enableOptionalDependencies;
|
||||
description = ''
|
||||
Whether to install GitLab CLI ({command}`glab`) as a dependency.
|
||||
This is useful if you work with GitLab repositories.
|
||||
|
||||
Defaults to the value of {option}`programs.claude-code.enableOptionalDependencies`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ] ++ lib.optional cfg.withGitLabCLI pkgs.glab;
|
||||
|
||||
# Enable integrated modules for dependencies when needed
|
||||
programs.git.enable = mkIf cfg.enableOptionalDependencies true;
|
||||
programs.gh.enable = mkIf cfg.withGitHubCLI true;
|
||||
programs.ripgrep.enable = mkIf cfg.enableOptionalDependencies true;
|
||||
|
||||
# Add activation script to disable auto-updates if the user wants that
|
||||
home.activation.disableClaudeAutoUpdates = lib.mkIf cfg.disableAutoUpdate
|
||||
(lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
$DRY_RUN_CMD ${
|
||||
lib.getExe cfg.package
|
||||
} config set -g autoUpdaterStatus disabled || true
|
||||
'');
|
||||
};
|
||||
}
|
|
@ -83,6 +83,7 @@ let
|
|||
"btop"
|
||||
"carapace"
|
||||
"cava"
|
||||
"claude-code"
|
||||
"cmus"
|
||||
"comodoro"
|
||||
"darcs"
|
||||
|
@ -294,6 +295,7 @@ in import nmtSrc {
|
|||
./modules/programs/btop
|
||||
./modules/programs/carapace
|
||||
./modules/programs/cava
|
||||
./modules/programs/claude-code
|
||||
./modules/programs/cmus
|
||||
./modules/programs/comodoro
|
||||
./modules/programs/darcs
|
||||
|
|
1
tests/modules/programs/claude-code/default.nix
Normal file
1
tests/modules/programs/claude-code/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ claude-code = ./test.nix; }
|
17
tests/modules/programs/claude-code/test.nix
Normal file
17
tests/modules/programs/claude-code/test.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
nixpkgs.overlays = [
|
||||
(self: super: {
|
||||
claude-code = pkgs.writeShellScriptBin "claude" ''
|
||||
echo "Claude Code CLI mock"
|
||||
'';
|
||||
})
|
||||
];
|
||||
|
||||
programs.claude-code = { enable = true; };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileRegex activate "claude config set -g autoUpdaterStatus disabled"
|
||||
'';
|
||||
}
|
Loading…
Add table
Reference in a new issue