{ lib, stdenv, fetchFromGitea, buildGoModule, makeWrapper, pkgs, alsa-utils }:
buildGoModule rec {
  pname = "voskcli";
  version = "5eedba33b96dcd3826010cbd12e404cbfb544383";
  vendorHash = "sha256-8l2i/fhN+2q+tjHpWdjRmesDDBBpxEPrTB8IE5Cr0I8=";
  src = fetchFromGitea {
    domain = "git.helcel.net";
    owner = "helcel";
    repo = pname;
    rev = version;
    sha256 = "sha256-TeCUtHuBGVyV+YmY3MGaf1jydTWgZITUgmUZzy4wZLU=";
  };
  preBuild = ''
    export CGO_CFLAGS="-I${pkgs.custom.vosk.base}/include"
    export CGO_LDFLAGS="-L${pkgs.custom.vosk.base}/lib"
  '';
  nativeBuildInputs = [ makeWrapper ];
  installPhase = ''
    runHook preInstall
    install -Dm755 $GOPATH/bin/voskcli -t $out/bin
    runHook postInstall
  '';
  postFixup = ''
    wrapProgram $out/bin/voskcli \
    --prefix PATH : ${lib.makeBinPath [ alsa-utils ]} \
    --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ stdenv.cc.cc.lib ]} \
  '';
}
