125 lines
3.7 KiB
Nix
125 lines
3.7 KiB
Nix
{
|
|
description = "Shell command helper";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
home-manager.url = "github:nix-community/home-manager";
|
|
};
|
|
|
|
outputs =
|
|
{
|
|
self,
|
|
nixpkgs,
|
|
flake-utils,
|
|
home-manager,
|
|
...
|
|
}@inputs:
|
|
(
|
|
let
|
|
inherit (lib) mkEnableOption mkPackageOption mkIf;
|
|
lib = nixpkgs.lib;
|
|
in
|
|
flake-utils.lib.eachDefaultSystem (
|
|
system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
in
|
|
{
|
|
packages.default = pkgs.buildGoModule {
|
|
pname = "llm-shell-hint";
|
|
version = "0.1.0";
|
|
src = ./.;
|
|
vendorHash = "sha256-7sFDSzjqA6TbWpTbiyxdIGAZ4UB3MoHP/OPUQw6rdz8=";
|
|
};
|
|
|
|
apps.default = {
|
|
type = "app";
|
|
program = "${self.packages.${system}.default}/bin/llm-shell-hint";
|
|
};
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
buildInputs = with pkgs; [
|
|
go
|
|
nixfmt
|
|
gopls
|
|
gotools
|
|
];
|
|
};
|
|
}
|
|
)
|
|
// {
|
|
homeManagerModules.default =
|
|
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
inherit (pkgs.stdenv.hostPlatform) system;
|
|
in
|
|
{
|
|
options.programs.llm-shell-hint = {
|
|
enable = lib.mkEnableOption "llm-shell-hint shell integration";
|
|
enableBashIntegration = lib.mkEnableOption "Bash integration";
|
|
enableFishIntegration = lib.mkEnableOption "Fish integration";
|
|
enableZshIntegration = lib.mkEnableOption "Zsh integration";
|
|
|
|
settings = lib.mkOption {
|
|
type =
|
|
with lib.types;
|
|
attrsOf (oneOf [
|
|
bool
|
|
int
|
|
float
|
|
str
|
|
(listOf str)
|
|
]);
|
|
default = { };
|
|
example = lib.literalExpression ''
|
|
{
|
|
LLMProviderURL = "https://openrouter.ai/api/v1/chat/completions";
|
|
APIKey = "your-api-key";
|
|
ShellType = "fish";
|
|
ModelName = "anthropic/claude-sonnet-4";
|
|
ColorScheme = "dark";
|
|
}
|
|
'';
|
|
description = ''
|
|
Configuration for llm-shell-hint.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config =
|
|
let
|
|
cfg = config.programs.llm-shell-hint;
|
|
tomlFormat = pkgs.formats.toml { };
|
|
configFile = tomlFormat.generate "llm-shell-hint-config" cfg.settings;
|
|
in
|
|
lib.mkIf cfg.enable {
|
|
home.packages = [ self.packages."${system}".default ];
|
|
|
|
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
|
${
|
|
lib.getExe self.packages."${system}".default
|
|
} init bash --config-file "${configFile}" | source
|
|
'';
|
|
|
|
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
|
${
|
|
lib.getExe self.packages."${system}".default
|
|
} init zsh --config-file "${configFile}" | source
|
|
'';
|
|
|
|
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
|
|
${
|
|
lib.getExe self.packages."${system}".default
|
|
} init fish --config-file "${configFile}" | source
|
|
'';
|
|
};
|
|
};
|
|
}
|
|
);
|
|
}
|