summary refs log tree commit diff
path: root/pkgs/applications/version-management/git-and-tools/hub/default.nix
blob: e0d7e46d22a51aea75b1ad3dde164ea5203fe134 (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
{ lib, buildGoPackage, fetchFromGitHub, git, groff, installShellFiles, util-linux, nixosTests }:

buildGoPackage rec {
  pname = "hub";
  version = "2.14.2";

  goPackagePath = "github.com/github/hub";

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

  src = fetchFromGitHub {
    owner = "github";
    repo = pname;
    rev = "v${version}";
    sha256 = "1qjab3dpia1jdlszz3xxix76lqrm4zbmqzd9ymld7h06awzsg2vh";
  };

  nativeBuildInputs = [ groff installShellFiles util-linux ];

  postPatch = ''
    patchShebangs .
    substituteInPlace git/git.go --replace "cmd.New(\"git\")" "cmd.New(\"${git}/bin/git\")"
    substituteInPlace commands/args.go --replace "Executable:  \"git\"" "Executable:  \"${git}/bin/git\""
  '';

  postInstall = ''
    cd go/src/${goPackagePath}
    installShellCompletion --zsh --name _hub etc/hub.zsh_completion
    installShellCompletion --bash --name hub etc/hub.bash_completion.sh
    installShellCompletion --fish --name hub.fish etc/hub.fish_completion

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

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

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