{ config
, lib
, pkgs
, ...
}:

with lib;
let
  cfg = config.my.programs.aider;

  wrapped = pkgs.writeShellApplication {
    name = "aider";
    text = ''
      aider --openai-api-key "$(cat /run/agenix/openai)" --anthropic-api-key "$(cat /run/agenix/anthropic)" --no-attribute-author --no-attribute-committer "$@"
    '';
    runtimeInputs = [ cfg.package ];
  };
in
{
  options.my.programs.aider = {
    enable = mkEnableOption "ssh";
    package = mkPackageOption pkgs "aider-chat" { };
  };

  config = mkIf cfg.enable {
    environment.systemPackages = [ wrapped ];
  };
}
