git-town: use buildGoModule

This commit is contained in:
Aaron Jheng 2022-06-04 06:49:53 +00:00
parent bd7aa1e1bf
commit 2128994aaa
No known key found for this signature in database
GPG key ID: F6A547A869D050A3

View file

@ -1,10 +1,9 @@
{ lib, buildGoPackage, fetchFromGitHub }: { lib, buildGoModule, fetchFromGitHub, installShellFiles, git, testers, git-town, makeWrapper }:
buildGoPackage rec { buildGoModule rec {
pname = "git-town"; pname = "git-town";
version = "7.7.0"; version = "7.7.0";
goPackagePath = "github.com/git-town/git-town";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "git-town"; owner = "git-town";
repo = "git-town"; repo = "git-town";
@ -12,12 +11,58 @@ buildGoPackage rec {
sha256 = "sha256-FpBEBx2gb33fGDndvZmvG1A61NoJ4Qy4V3YQSb+Ugsc="; sha256 = "sha256-FpBEBx2gb33fGDndvZmvG1A61NoJ4Qy4V3YQSb+Ugsc=";
}; };
ldflags = [ "-X github.com/git-town/git-town/src/cmd.version=v${version}" "-X github.com/git-town/git-town/src/cmd.buildDate=nix" ]; vendorSha256 = null;
nativeBuildInputs = [ installShellFiles makeWrapper ];
buildInputs = [ git ];
ldflags =
let
modulePath = "github.com/git-town/git-town/v${lib.versions.major version}"; in
[
"-s"
"-w"
"-X ${modulePath}/src/cmd.version=v${version}"
"-X ${modulePath}/src/cmd.buildDate=nix"
];
checkInputs = [ git ];
preCheck =
let
skippedTests = [
"TestGodog"
"TestRunner_CreateChildFeatureBranch"
"TestShellRunner_RunStringWith_Dir"
"TestMockingShell_MockCommand"
"TestShellRunner_RunStringWith_Input"
];
in
''
HOME=$(mktemp -d)
# Disable tests requiring local operations
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
'';
postInstall = ''
installShellCompletion --cmd git-town \
--bash <($out/bin/git-town completion bash) \
--fish <($out/bin/git-town completion fish) \
--zsh <($out/bin/git-town completion zsh)
wrapProgram $out/bin/git-town --prefix PATH : ${lib.makeBinPath [ git ]}
'';
passthru.tests.version = testers.testVersion {
package = git-town;
command = "git-town version";
version = "v${version}";
};
meta = with lib; { meta = with lib; {
description = "Generic, high-level git support for git-flow workflows"; description = "Generic, high-level git support for git-flow workflows";
homepage = "https://www.git-town.com/"; homepage = "https://www.git-town.com/";
maintainers = [ maintainers.allonsy maintainers.blaggacao ];
license = licenses.mit; license = licenses.mit;
maintainers = with maintainers; [ allonsy blaggacao ];
}; };
} }