From ebaa810d8309620d08d16a0a42c8c26e9ccbf3c5 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Mon, 23 Oct 2023 03:10:07 +0200 Subject: [PATCH] moved dendrite around --- nixos/components/terminal/default.nix | 1 + nixos/components/terminal/heygpt.nix | 25 +++++++++++++++++++ nixos/machines/robi/configuration.nix | 2 +- .../{dendrite.nix => terranix-dendrite.nix} | 0 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 nixos/components/terminal/heygpt.nix rename nixos/machines/robi/{dendrite.nix => terranix-dendrite.nix} (100%) diff --git a/nixos/components/terminal/default.nix b/nixos/components/terminal/default.nix index 28fbe3f..7d5f975 100644 --- a/nixos/components/terminal/default.nix +++ b/nixos/components/terminal/default.nix @@ -11,6 +11,7 @@ with lib; imports = [ ./direnv.nix ./git.nix + ./heygpt.nix ./hoard.nix ./oh-my-posh ./remote-install.nix diff --git a/nixos/components/terminal/heygpt.nix b/nixos/components/terminal/heygpt.nix new file mode 100644 index 0000000..32bf609 --- /dev/null +++ b/nixos/components/terminal/heygpt.nix @@ -0,0 +1,25 @@ +{ config, lib, pkgs, ... }: +with lib; +{ + options.components.terminal.heygpt.enable = mkOption { + type = lib.types.bool; + default = config.components.terminal.enable; + }; + + 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.unstable.heygpt} "$@" + '') + (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 + '') + ]; + }; +} diff --git a/nixos/machines/robi/configuration.nix b/nixos/machines/robi/configuration.nix index e26bea7..98661a4 100644 --- a/nixos/machines/robi/configuration.nix +++ b/nixos/machines/robi/configuration.nix @@ -50,7 +50,7 @@ #./property.nix # flask sucks, find something else # matrix - ./dendrite.nix + ./terranix-dendrite.nix # logging ./loki.nix diff --git a/nixos/machines/robi/dendrite.nix b/nixos/machines/robi/terranix-dendrite.nix similarity index 100% rename from nixos/machines/robi/dendrite.nix rename to nixos/machines/robi/terranix-dendrite.nix