{
  lib,
  buildGoModule,
  fetchFromGitHub,
  stdenv,
  darwin,
  xorg,
  pkg-config,
  wayland,
  libGL,
  libxkbcommon,
  makeWrapper,
}:

buildGoModule rec {
  pname = "nerdlog";
  version = "1.10.0";

  src = fetchFromGitHub {
    owner = "dimonomid";
    repo = "nerdlog";
    rev = "v${version}";
    hash = "sha256-XlzWNeyd+Ar4ArFcN1wkQ0aod6ckAiIb12odK7cf4+s=";
  };

  vendorHash = "sha256-hvv0dsE1yz85VLaBOE7RWbux8L8kVTihcA1HyyHRYAM=";

  subPackages = [
    "cmd/nerdlog"
    "cmd/generate_syslog"
  ];

  doCheck = false;

  nativeBuildInputs = [
    pkg-config
    makeWrapper
  ];

  buildInputs =
    lib.optionals stdenv.isDarwin [
      darwin.apple_sdk.frameworks.Cocoa
    ]
    ++ lib.optionals stdenv.isLinux [
      xorg.libX11
      xorg.libXext
      xorg.libXfixes
      wayland
      libGL
      libxkbcommon
    ];

  postInstall = lib.optionalString stdenv.isLinux ''
    wrapProgram $out/bin/nerdlog \
      --prefix LD_LIBRARY_PATH : ${
        lib.makeLibraryPath [
          xorg.libX11
          xorg.libXext
          xorg.libXfixes
          wayland
          libGL
          libxkbcommon
        ]
      }
  '';

  ldflags = [
    "-s"
    "-w"
    "-X=github.com/dimonomid/nerdlog/version.version=${version}"
    "-X=github.com/dimonomid/nerdlog/version.commit=${src.rev}"
    "-X=github.com/dimonomid/nerdlog/version.date=1970-01-01T00:00:00Z"
    "-X=github.com/dimonomid/nerdlog/version.builtBy=goreleaser"
  ];

  meta = {
    description = "Nerdlog: fast, remote-first, multi-host TUI log viewer with timeline histogram and no central server";
    homepage = "https://github.com/dimonomid/nerdlog";
    changelog = "https://github.com/dimonomid/nerdlog/blob/${src.rev}/CHANGELOG.md";
    license = lib.licenses.bsd2;
    mainProgram = "nerdlog";
  };
}
