nixpkgs/pkgs/applications/version-management/git-and-tools/hub/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

48 lines
1.4 KiB
Nix

{ lib, stdenv, 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;
};
}