add ai tools package on my nix configs

This commit is contained in:
Rasyidan Akbar F. 2025-09-30 14:07:56 +07:00
commit ac8cedebe4
8 changed files with 235 additions and 1891 deletions

85
flake.lock generated
View file

@ -1,5 +1,27 @@
{
"nodes": {
"blueprint": {
"inputs": {
"nixpkgs": [
"nix-ai-tools",
"nixpkgs"
],
"systems": "systems_2"
},
"locked": {
"lastModified": 1758687491,
"narHash": "sha256-sy8Q+MfBe+MZzYj4MJwBDe4lkLnmhy1POO86hWZgqO8=",
"owner": "numtide",
"repo": "blueprint",
"rev": "7ecaeb70f63d14a397c73b38f57177894bb795c8",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "blueprint",
"type": "github"
}
},
"crane": {
"locked": {
"lastModified": 1753316655,
@ -111,7 +133,7 @@
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
"systems": "systems_3"
},
"locked": {
"lastModified": 1731533236,
@ -129,7 +151,7 @@
},
"flake-utils_3": {
"inputs": {
"systems": "systems_3"
"systems": "systems_4"
},
"locked": {
"lastModified": 1731533236,
@ -205,6 +227,28 @@
"type": "github"
}
},
"nix-ai-tools": {
"inputs": {
"blueprint": "blueprint",
"nixpkgs": [
"nixpkgs"
],
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1759202406,
"narHash": "sha256-S/MNZpRL7ipUHjIcxm3lUOwHZP8+TyqhV8NhyG0ylZ8=",
"owner": "numtide",
"repo": "nix-ai-tools",
"rev": "bc955591be58fe04dde01996cf4bbbc4bcc20f6f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "nix-ai-tools",
"type": "github"
}
},
"nix-appimage": {
"inputs": {
"flake-compat": "flake-compat_2",
@ -285,6 +329,7 @@
"darwin": "darwin",
"ghostty": "ghostty",
"home-manager": "home-manager",
"nix-ai-tools": "nix-ai-tools",
"nixpkgs": "nixpkgs_2",
"nvim-bundle": "nvim-bundle"
}
@ -356,6 +401,42 @@
"type": "github"
}
},
"systems_4": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nix-ai-tools",
"nixpkgs"
]
},
"locked": {
"lastModified": 1758728421,
"narHash": "sha256-ySNJ008muQAds2JemiyrWYbwbG+V7S5wg3ZVKGHSFu8=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "5eda4ee8121f97b218f7cc73f5172098d458f1d1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"zig": {
"inputs": {
"flake-compat": [

View file

@ -14,9 +14,13 @@
nvim-bundle.url = "github:jla2000/nvim-bundle";
nvim-bundle.inputs.nixpkgs.follows = "nixpkgs";
nix-ai-tools.url = "github:numtide/nix-ai-tools";
nix-ai-tools.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ self, nixpkgs, darwin, home-manager, ghostty, ... }:
outputs =
inputs@{ self, nixpkgs, darwin, home-manager, ghostty, nix-ai-tools, ... }:
let
inherit (nixpkgs.lib) genAttrs;

View file

@ -17,7 +17,6 @@ in {
duckdb
ffmpeg
fzf
go
htop
jetbrains-mono
jq
@ -26,18 +25,12 @@ in {
lorri
neovim
pandoc
postgresql_18
python312
python312Packages.uv
ripgrep
rustc
rustup
tree
vim
yq
tmux
tailscale
sqlite
wget
];
description = "System packages to install for development tooling.";

View file

@ -5,26 +5,20 @@
./programs/helix.nix
./programs/neovim.nix
./programs/ghostty.nix
./shell/zsh.nix
./shell/nushell.nix
./shell/tmux.nix
./devtools/ai-tools.nix
./devtools/default.nix
];
rsydn.shell.zsh = {
enable = true;
enableVimMode = true;
powerlevel10kConfigFile = ./shell/p10k.zsh;
aliases = { ll = "ls -alF"; };
extraAfter = ''
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
'';
};
programs.nushell.enable = true;
programs.git.enable = true;
home.packages = with pkgs; [ docker docker-compose ];
rsydn.aiTools.enable = lib.mkDefault true;
rsydn.devTools = {
enable = lib.mkDefault true;
packages = with pkgs; [ bun cloudflared ];

View file

@ -0,0 +1,141 @@
{ config, lib, pkgs, inputs, ... }:
let
inherit (lib) mkEnableOption mkOption types mkIf concatMap unique warn;
cfg = config.rsydn.aiTools;
nodePackages = if builtins.hasAttr "nodePackages_latest" pkgs then
pkgs.nodePackages_latest
else if builtins.hasAttr "nodePackages" pkgs then
pkgs.nodePackages
else
{ };
hasNodePackage = name: builtins.hasAttr name nodePackages;
getNodePackage = name:
if hasNodePackage name then nodePackages.${name} else null;
choosePackage = packages:
let filtered = lib.filter (pkg: pkg != null) packages;
in if filtered == [ ] then null else lib.head filtered;
codexDefault = choosePackage [ (getNodePackage "@openai/codex") ];
crushFromInput = if builtins.hasAttr "nix-ai-tools" inputs then
let
pkgSet = inputs."nix-ai-tools".packages or { };
system = pkgs.stdenv.hostPlatform.system;
in if builtins.hasAttr system pkgSet then
let systemPackages = builtins.getAttr system pkgSet;
in if builtins.hasAttr "crush" systemPackages then
builtins.getAttr "crush" systemPackages
else
null
else
null
else
null;
crushDefault =
choosePackage [ crushFromInput (getNodePackage "@charmland/crush") ];
opencodeDefault = choosePackage [ (getNodePackage "opencode-ai") ];
claudeDefault =
choosePackage [ (getNodePackage "@anthropic-ai/claude-code") ];
toolOption = { name, description, defaultPackage }:
mkOption {
type = types.submodule {
options = {
enable = mkOption {
type = types.bool;
default = true;
description = "Enable the ${name} CLI.";
};
package = mkOption {
type = types.nullOr types.package;
default = defaultPackage;
description =
"Package providing ${name}. Set to null to skip installation.";
};
};
};
default = {
enable = true;
package = defaultPackage;
};
description = description;
};
gatherToolPackages = tools:
concatMap (tool:
let
name = tool.name;
cfgTool = tool.cfg;
in if cfgTool.enable then
if cfgTool.package != null then
[ cfgTool.package ]
else
warn "rsydn.aiTools.${name}: package is null, skipping install" [ ]
else
[ ]) tools;
toolPackages = gatherToolPackages [
{
name = "codex";
cfg = cfg.codex;
}
{
name = "crush";
cfg = cfg.crush;
}
{
name = "opencode";
cfg = cfg.opencode;
}
{
name = "claude";
cfg = cfg.claude;
}
];
in {
options.rsydn.aiTools = {
enable = mkEnableOption "AI-oriented command line tooling";
codex = toolOption {
name = "Codex";
description = "OpenAI Codex CLI (npm @openai/codex).";
defaultPackage = codexDefault;
};
crush = toolOption {
name = "Crush";
description = "Charmbracelet Crush CLI for natural language shell.";
defaultPackage = crushDefault;
};
opencode = toolOption {
name = "OpenCode";
description = "OpenCode AI collaborative CLI.";
defaultPackage = opencodeDefault;
};
claude = toolOption {
name = "Claude Code";
description = "Anthropic Claude Code CLI assistant.";
defaultPackage = claudeDefault;
};
extraPackages = mkOption {
type = types.listOf types.package;
default = [ ];
description =
"Additional AI tooling packages to add alongside the defaults.";
};
};
config = mkIf cfg.enable {
home.packages = unique (toolPackages ++ cfg.extraPackages);
};
}

View file

@ -0,0 +1 @@
{ lib, ... }: { programs.nushell.enable = lib.mkDefault true; }

File diff suppressed because it is too large Load diff

View file

@ -1,124 +0,0 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkEnableOption mkIf mkMerge mkOption types;
cfg = config.rsydn.shell.zsh;
in {
options.rsydn.shell.zsh = {
enable = mkEnableOption "user zsh configuration managed by Home Manager";
theme = mkOption {
type = types.str;
default = "powerlevel10k/powerlevel10k";
description =
"Prompt theme identifier (powerlevel10k supported out of the box).";
};
aliases = mkOption {
type = types.attrsOf types.str;
default = { };
description = "Zsh command aliases.";
};
extraBeforeCompInit = mkOption {
type = types.lines;
default = ''
if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then
source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh"
fi
'';
description =
"Extra script executed before compinit (useful for instant prompt).";
};
extraAfter = mkOption {
type = types.lines;
default = "";
description =
"Additional script appended after the standard zsh setup runs.";
};
promptInit = mkOption {
type = types.lines;
default = "";
description =
"Custom prompt initialization snippet appended after theme setup.";
};
powerlevel10kConfigFile = mkOption {
type = types.nullOr types.path;
default = null;
description =
"Optional path to a Powerlevel10k config that will be linked to ~/.p10k.zsh.";
};
enableAutoSuggestion = mkOption {
type = types.bool;
default = true;
description = "Enable zsh-autosuggestions.";
};
autosuggestAcceptWidgets = mkOption {
type = types.listOf types.str;
default = [
"forward-char"
"end-of-line"
"vi-forward-char"
"vi-end-of-line"
"vi-add-eol"
"expand-or-complete"
"complete-word"
"fzf-completion"
];
description =
"Widgets that should accept autosuggestions before running (ZSH_AUTOSUGGEST_ACCEPT_WIDGETS).";
};
enableSyntaxHighlighting = mkOption {
type = types.bool;
default = true;
description = "Enable zsh-syntax-highlighting.";
};
enableVimMode = mkOption {
type = types.bool;
default = false;
description = "Enable vi keybindings by running bindkey -v.";
};
};
config = mkIf cfg.enable (mkMerge [
{
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = cfg.enableAutoSuggestion;
syntaxHighlighting.enable = cfg.enableSyntaxHighlighting;
shellAliases = cfg.aliases;
initContent = lib.mkAfter cfg.extraAfter;
localVariables = lib.mkIf cfg.enableAutoSuggestion {
ZSH_AUTOSUGGEST_ACCEPT_WIDGETS = cfg.autosuggestAcceptWidgets;
};
};
}
{ programs.zsh.initContent = lib.mkOrder 550 cfg.extraBeforeCompInit; }
(mkIf (cfg.theme == "powerlevel10k/powerlevel10k") {
programs.zsh.initExtraFirst = lib.mkBefore ''
source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme
'';
})
(mkIf (cfg.powerlevel10kConfigFile != null) {
home.file.".p10k.zsh".source = cfg.powerlevel10kConfigFile;
programs.zsh.initExtraFirst = lib.mkAfter ''
source ~/.p10k.zsh
'';
})
(mkIf (cfg.promptInit != "") {
programs.zsh.initExtraFirst = lib.mkAfter cfg.promptInit;
})
(mkIf cfg.enableVimMode {
programs.zsh.initContent = lib.mkBefore ''
bindkey -v
'';
})
]);
}