{
  lib,
  stdenv,
  fetchFromGitHub,
  meson,
  ninja,
  blueprint-compiler,
  pkg-config,
  gettext,
  desktop-file-utils,
  glib,
  appstream-glib,
  appstream,
  gjs,
  gtk4,
  libadwaita,
  wrapGAppsHook4,
}:

stdenv.mkDerivation rec {
  pname = "dosage";
  version = "1.9.11";

  src = fetchFromGitHub {
    owner = "diegopvlk";
    repo = "Dosage";
    rev = "v${version}";
    hash = "sha256-TS9niQd3jlALQrFu6H2SucZwwQp0k2BRHqZCYfbz+CI=";
  };

  nativeBuildInputs = [
    meson
    ninja
    blueprint-compiler
    pkg-config
    gettext
    desktop-file-utils
    glib
    appstream-glib
    appstream
    wrapGAppsHook4
  ];

  buildInputs = [
    gjs
    gtk4
    libadwaita
    glib
  ];

  # Ensure GResource files are properly accessible
  postInstall = ''
    # The GResource files should be automatically handled by wrapGAppsHook4
    # but let's make sure the GResource path is correct
    wrapProgram $out/bin/io.github.diegopvlk.Dosage \
      --prefix XDG_DATA_DIRS : "$out/share:$GSETTINGS_SCHEMAS_PATH"
  '';

  meta = {
    description = "Medication tracker for Linux";
    homepage = "https://github.com/diegopvlk/Dosage";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [ ];
    mainProgram = "io.github.diegopvlk.Dosage";
    platforms = lib.platforms.all;
  };
}
