Commit 9b301c5b authored by ZHAO Jin-Xiang's avatar ZHAO Jin-Xiang
Browse files

wtfutil: fix wtfutil --version

parent f6a0f156
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  buildGoModule,
  fetchFromGitHub,
  lib,
  makeWrapper,
  ncurses,
  versionCheckHook,
  nix-update-script,
}:

buildGoModule rec {
@@ -25,18 +28,28 @@ buildGoModule rec {
  ldflags = [
    "-s"
    "-w"
    "-X main.version=${version}"
  ];

  subPackages = [ "." ];

  nativeBuildInputs = [ makeWrapper ];

  postPatch = ''
    substituteInPlace flags/flags.go --replace-fail 'version := "dev"' 'version := "v${version}"'
  '';

  postInstall = ''
    mv "$out/bin/wtf" "$out/bin/wtfutil"
    wrapProgram "$out/bin/wtfutil" --prefix PATH : "${ncurses.dev}/bin"
  '';

  doInstallCheck = true;
  # Darwin Error: mkdir /var/empty: file exists
  nativeInstallCheckInputs = lib.optional (!stdenv.hostPlatform.isDarwin) [ versionCheckHook ];
  versionCheckProgramArg = "--version";

  passthru.updateScript = nix-update-script { };

  meta = with lib; {
    description = "Personal information dashboard for your terminal";
    homepage = "https://wtfutil.com/";