{ lib, pkgs, ... }:
{
  # this predates the home-manager module, and that kinda sucks anyway due to repeated keys in the config file
  home.packages = [ pkgs.ghostty ];
  home.file.".config/ghostty/config" = {
    force = true;
    # source = ./ghosty.config;
    # onChange = ''
    #   ${lib.getExe pkgs.ghostty} +validate-config --config-file=${./ghosty.config}
    # '';
    source = pkgs.runCommand "validated-ghosty.config" {
      preferLocalBuild = true;
      nativeBuildInputs = [ pkgs.ghostty ];
    } ''
      # echo >&2 + ghostty +validate-config --config-file=${./ghosty.config}
      (
        set -x
        ghostty +validate-config --config-file=${./ghosty.config}
      )
      ln -s ${./ghosty.config} $out
    '';
  };

  # bash integration, optional
  # https://ghostty.org/docs/features/shell-integration#manual-shell-integration-setup

  # Make order 101 to be placed exactly after bash completions, as Ghostty
  # documentation suggests sourcing the script as soon as possible
  programs.bash.initExtra = lib.mkOrder 101 ''
    if [[ -n "''${GHOSTTY_RESOURCES_DIR}" ]]; then
      builtin source "''${GHOSTTY_RESOURCES_DIR}/shell-integration/bash/ghostty.bash"
    fi
  '';

  # try to make nautilus use this as the default gnome-console/gnome-terminal

  # dconf.settings."org/gnome/desktop/default-applications/terminal" = {
  dconf.settings."org/gnome/desktop/default/applications/terminal" = {
    # exec = lib.getExe pkgs.ghostty;
    exec = "ghostty";
    # exec-arg = "-e";
  };
}
