{ lib, rustPlatform, sqlite, openssl, gettext, pkg-config, commitShaShort ? "" }:

rustPlatform.buildRustPackage rec {
  pname = "hagrid";
  version = "2.0.1";

  src = ./.;
  cargoLock = {
    lockFile = ./Cargo.lock;
    outputHashes = {
      "rocket_i18n-0.5.0" = "sha256-EbUE8Z3TQBnDnptl9qWK6JvsACCgP7EXTxcA7pouYbc=";
    };
  };

  postInstall = ''
    cp -r dist $out
  '';

  nativeBuildInputs = [
    pkg-config
    gettext
  ];

  buildInputs = [
    sqlite
    openssl
  ];

  COMMIT_SHA_SHORT = commitShaShort;

  meta = with lib; {
    description = "A verifying keyserver";
    homepage = "https://gitlab.com/keys.openpgp.org/hagrid";
    license = with licenses; [ gpl3 ];
    maintainers = with maintainers; [ valodim ];
    platforms = platforms.all;
  };
}
