{
  pkgs,
  lib,
  config,
  ...
}: let
  cfg = config.mods.terminal;

  hr = pkgs.writeShellScriptBin "hr" (builtins.readFile ./hr.sh);
in {
  options.mods.terminal.hr.enable = lib.mkEnableOption "Hefring (Work Tooling)";

  config = lib.mkIf cfg.hr.enable {
    programs.starship.settings.custom.project_id = {
      command = "if echo \"$PROJECT_ID\" | grep -q \"prod\"; then printf \"\\033[1;33m \\033[1;34m$PROJECT_ID\\033[0m\"; else printf \"\\033[1;34m$PROJECT_ID\\033[0m\"; fi";
      when = "test -n \"$PROJECT_ID\"";
      format = "on $output ";
    };

    programs.zsh.initExtra = ''
      export MK2_TEST_SQL_INSTANCE_USER=gijs
      export MK2_TEST_SQL_INSTANCE_PASSWORD="$(cat ${config.sops.secrets.google-db-test.path})"
      export MK2_TEST_SQL_INSTANCE_PORT=5436
      export MK2_TEST_SQL_INSTANCE_HOST=localhost
      export MK2_PROD_SQL_INSTANCE_USER=gijs
      export MK2_PROD_SQL_INSTANCE_PASSWORD="$(cat ${config.sops.secrets.google-db-prod.path})"
      export MK2_PROD_SQL_INSTANCE_HOST=localhost
      export MK2_PROD_SQL_INSTANCE_PORT=5437
    '' + builtins.readFile ./hr.sh;

    systemd.user.services = {
      google-db-proxy-test = {
        Unit = {
          Description = "Google Cloud SQL Proxy (Test)";
          After = ["network.target"];
        };
        Service = {
          ExecStart = "${pkgs.google-cloud-sql-proxy}/bin/cloud-sql-proxy mk2-test:europe-west1:mk2-test-sql-instance -p 5436";
          Restart = "always";
        };
        Install = {
          WantedBy = ["default.target"];
        };
      };

      google-db-proxy-prod = {
        Unit = {
          Description = "Google Cloud SQL Proxy (Prod)";
          After = ["network.target"];
        };
        Service = {
          ExecStart = "${pkgs.google-cloud-sql-proxy}/bin/cloud-sql-proxy mk2-prod:europe-west1:mk2-prod-sql-instance -p 5437";
          Restart = "always";
        };
        Install = {
          WantedBy = ["default.target"];
        };
      };
    };
  };
}
