modue stuff

This commit is contained in:
Alexander Khodyrev 2025-08-26 21:31:30 +03:00
parent 97fd7e7b1a
commit 1f8cd90ee4

128
flake.nix
View file

@ -7,15 +7,24 @@
home-manager.url = "github:nix-community/home-manager"; home-manager.url = "github:nix-community/home-manager";
}; };
outputs = { self, nixpkgs, flake-utils, home-manager, ... }@inputs: outputs =
{
self,
nixpkgs,
flake-utils,
home-manager,
...
}@inputs:
let let
inherit (lib) mkEnableOption mkPackageOption mkIf; inherit (lib) mkEnableOption mkPackageOption mkIf;
lib = nixpkgs.lib; lib = nixpkgs.lib;
in in
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (
system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
in { in
{
packages.default = pkgs.buildGoModule { packages.default = pkgs.buildGoModule {
pname = "llm-shell-hint"; pname = "llm-shell-hint";
version = "0.1.0"; version = "0.1.0";
@ -37,58 +46,71 @@
]; ];
}; };
homeManagerModules.default = { config, lib, pkgs, ... }: { homeManagerModules.default =
options.programs.llm-shell-hint = { {
enable = lib.mkEnableOption "llm-shell-hint shell integration"; config,
package = lib.mkPackageOption pkgs "llm-shell-hint" { }; lib,
enableBashIntegration = lib.mkEnableOption "Bash integration"; pkgs,
enableFishIntegration = lib.mkEnableOption "Fish integration"; ...
enableZshIntegration = lib.mkEnableOption "Zsh integration"; }:
let
settings = lib.mkOption { inherit (pkgs.stdenv.hostPlatform) system;
type = with lib.types; attrsOf (oneOf [ in
bool {
int options.programs.llm-shell-hint = {
float enable = lib.mkEnableOption "llm-shell-hint shell integration";
str enableBashIntegration = lib.mkEnableOption "Bash integration";
(listOf str) enableFishIntegration = lib.mkEnableOption "Fish integration";
]); enableZshIntegration = lib.mkEnableOption "Zsh integration";
default = {};
example = lib.literalExpression '' settings = lib.mkOption {
{ type =
LLMProviderURL = "https://openrouter.ai/api/v1/chat/completions"; with lib.types;
APIKey = "your-api-key"; attrsOf (oneOf [
ShellType = "fish"; bool
ModelName = "anthropic/claude-sonnet-4"; int
ColorScheme = "dark"; float
} str
''; (listOf str)
description = '' ]);
Configuration for llm-shell-hint. 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
mkIf cfg.enable {
home.packages = [ self.packages."${system}".llm-shell-hint ];
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
${lib.getExe self.packages."${system}".llm-shell-hint} init bash --config-file "${configFile}" | source
'';
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
${lib.getExe self.packages."${system}".llm-shell-hint} init zsh --config-file "${configFile}" | source
'';
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
${lib.getExe self.packages."${system}".llm-shell-hint} init fish --config-file "${configFile}" | source
'';
};
}; };
config = let
cfg = config.programs.llm-shell-hint;
tomlFormat = pkgs.formats.toml { };
configFile = tomlFormat.generate "llm-shell-hint-config" cfg.settings;
in mkIf cfg.enable {
home.packages = [ cfg.package ];
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
${lib.getExe cfg.package} init bash --config-file "${configFile}" | source
'';
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
${lib.getExe cfg.package} init zsh --config-file "${configFile}" | source
'';
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
${lib.getExe cfg.package} init fish --config-file "${configFile}" | source
'';
};
};
} }
); );
} }