about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/version-management/hub/default.nix
blob: 4486c71605da395f31f261f13145dbf821ecc8ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{ lib
, buildGoModule
, fetchpatch
, fetchFromGitHub
, git
, groff
, installShellFiles
, makeWrapper
, unixtools
, nixosTests
}:

buildGoModule rec {
  pname = "hub";
  version = "unstable-2022-12-01";

  src = fetchFromGitHub {
    owner = "github";
    repo = pname;
    rev = "38bcd4ae469e5f53f01901340b715c7658ab417a";
    hash = "sha256-V2GvwKj0m2UXxE42G23OHXyAsTrVRNw1p5CAaJxGYog=";
  };

  patches = [
    # Fix `fish` completions
    # https://github.com/github/hub/pull/3036
    (fetchpatch {
      url = "https://github.com/github/hub/commit/439b7699e79471fc789929bcdea2f30bd719963e.patch";
      hash = "sha256-pR/OkGa2ICR4n1pLNx8E2UTtLeDwFtXxeeTB94KFjC4=";
    })
    # Fix `bash` completions
    # https://github.com/github/hub/pull/2948
    (fetchpatch {
      url = "https://github.com/github/hub/commit/64b291006f208fc7db1d5be96ff7db5535f1d853.patch";
      hash = "sha256-jGFFIvSKEIpTQY0Wz63cqciUk25MzPHv5Z1ox8l7wmo=";
    })
  ];

  postPatch = ''
    patchShebangs script/
    sed -i 's/^var Version = "[^"]\+"$/var Version = "${version}"/' version/version.go
  '';

  vendorHash = "sha256-wQH8V9jRgh45JGs4IfYS1GtmCIYdo93JG1UjJ0BGxXk=";

  # Only needed to build the man-pages
  excludedPackages = [ "github.com/github/hub/md2roff-bin" ];

  nativeBuildInputs = [
    groff
    installShellFiles
    makeWrapper
    unixtools.col
  ];

  postInstall = ''
    installShellCompletion --cmd hub \
      --bash etc/hub.bash_completion.sh \
      --fish etc/hub.fish_completion \
      --zsh etc/hub.zsh_completion

    LC_ALL=C.UTF8 make man-pages
    installManPage share/man/man[1-9]/*.[1-9]

    wrapProgram $out/bin/hub \
      --suffix PATH : ${lib.makeBinPath [ git ]}
  '';

  nativeCheckInputs = [
    git
  ];

  passthru.tests = { inherit (nixosTests) hub; };

  meta = with lib; {
    description = "Command-line wrapper for git that makes you better at GitHub";
    homepage = "https://hub.github.com/";
    license = licenses.mit;
    maintainers = with maintainers; [ globin ];
  };
}