{ lib, rustPlatform, fetchFromGitHub }:
rustPlatform.buildRustPackage rec {
  pname = "matrix-authentication-service";
  version = "0.9.0";

  src = fetchFromGitHub {
    owner = "matrix-org";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-e5JlkcSJ44iE+pVnGQpGiSNahxUcIFeaPyOjp9E3eD0=";
  };
  cargoLock = {
    lockFile = "${src}/Cargo.lock";
    outputHashes = {
      "opa-wasm-0.1.0" = "sha256-f3IIln7BbN7NJiCVMgfoell/plzlqkSm4YYK7mqzKgw=";
    };
  };

  meta = with lib;
    {
      description = "O.uth2.0 + OpenID Provider for Matrix Homeservers";
      homepage = "https://github.com/matrix-org/matrix-authentication-service/blob/main/LICENSE";
      license = with licenses; [ asl20 ];
      maintainers = with maintainers; [ therealr5 ];
      mainProgram = "mas-cli";
    };
}