{
  lib,
  stdenv,
  fetchFromGitLab,
  makeWrapper,
  python3,
  gtk4,
  libadwaita,
  wrapGAppsHook4,
}:

stdenv.mkDerivation rec {
  pname = "hexcolordle-gtk";
  version = "1.0.3";

  src = fetchFromGitLab {
    owner = "Krafting";
    repo = "hexcolordle-gtk";
    rev = version;
    hash = "sha256-oPGC0D7sh+H25qg2ttRtIMjI+HjZImRieWmYw+I6sQE=";
  };

  nativeBuildInputs = [
    makeWrapper
    wrapGAppsHook4
  ];

  buildInputs = [
    gtk4
    libadwaita
    (python3.withPackages (
      ps: with ps; [
        pygobject3
        pycairo
      ]
    ))
  ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin $out/share/hexcolordle-gtk $out/share/applications $out/share/metainfo
    cp -r * $out/share/hexcolordle-gtk/

    # Install desktop file and metainfo
    cp net.krafting.HexColordle.desktop $out/share/applications/
    cp net.krafting.HexColordle.metainfo.xml $out/share/metainfo/

    # Create wrapper for the main Python file
    makeWrapper ${
      python3.withPackages (
        ps: with ps; [
          pygobject3
          pycairo
        ]
      )
    }/bin/python3 $out/bin/hexcolordle-gtk \
      --add-flags "$out/share/hexcolordle-gtk/HexColordle.py" \
      --prefix PYTHONPATH : "$out/share/hexcolordle-gtk"

    runHook postInstall
  '';

  meta = {
    description = "A game where you need to find a color by guessing its hex code";
    homepage = "https://gitlab.com/Krafting/hexcolordle-gtk";
    changelog = "https://gitlab.com/Krafting/hexcolordle-gtk/-/blob/${src.rev}/NEWS";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [ ];
    mainProgram = "hexcolordle-gtk";
    platforms = lib.platforms.all;
  };
}
