{ pkgs
, lib
, config
, ... }: with lib; let
  cfg = config.home.gyroflow;
in {
  options.home.gyroflow = {
    enable = mkEnableOption "gyroflow stabilisation software";
    package = mkOption {
      type = with types; package;
      default = pkgs.gyroflow.overrideAttrs (finalAttrs: previousAttrs: {
        buildInputs = previousAttrs.buildInputs ++ [ pkgs.qt6Packages.qtwayland ];
      });
      description = "gyroflow package";
    };
  };

  config = {
    users.homeModules = [
      # this module passes gyroflow configuration to home-manager
      { passthrough.gyroflow = cfg; }
    ];

    users.home.persist.directories = mkIf cfg.enable [ ".config/Gyroflow" ];
  };
}
