1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-31 04:04:32 +00:00
This commit is contained in:
Malo Bourgon 2025-03-30 15:05:12 +07:00 committed by GitHub
commit 4d61162264
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 96 additions and 0 deletions

View file

@ -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

View 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
'');
};
}

View file

@ -83,6 +83,7 @@ let
"btop"
"carapace"
"cava"
"claude-code"
"cmus"
"comodoro"
"darcs"
@ -295,6 +296,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

View file

@ -0,0 +1 @@
{ claude-code = ./test.nix; }

View 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"
'';
}