nixos-config/components/terminal/heygpt.nix

27 lines
847 B
Nix
Raw Normal View History

2023-10-23 03:10:07 +02:00
{ config, lib, pkgs, ... }:
with lib;
{
options.components.terminal.heygpt.enable = mkOption {
type = lib.types.bool;
2023-11-03 14:42:18 +01:00
#default = config.components.terminal.enable;
default = false;
2023-10-23 03:10:07 +02:00
};
config = mkIf (config.components.terminal.heygpt.enable) {
environment.systemPackages = [
(pkgs.writers.writeBashBin "heygpt" ''
export OPENAI_API_BASE="https://api.openai.com/v1"
export OPENAI_API_KEY=$(pass openai/apikey)
${lib.getExe pkgs.heygpt} "$@"
2023-10-23 03:10:07 +02:00
'')
(pkgs.writers.writeBashBin "heygpt-models" ''
export OPENAI_API_KEY=$(pass openai/apikey)
${getExe pkgs.curl} https://api.openai.com/v1/models \
-H "Authorization: Bearer $OPENAI_API_KEY" \
| ${getExe pkgs.jq} --raw-output '.data[] | .id' \
| ${getExe pkgs.gum} filter
'')
];
};
}