From 2128994aaa9b60e343ca40d36ae1e86cb0e78564 Mon Sep 17 00:00:00 2001 From: Aaron Jheng Date: Sat, 4 Jun 2022 06:49:53 +0000 Subject: [PATCH] git-town: use buildGoModule --- pkgs/tools/misc/git-town/default.nix | 55 +++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/pkgs/tools/misc/git-town/default.nix b/pkgs/tools/misc/git-town/default.nix index 1afacc4b4b89..618d627921ba 100644 --- a/pkgs/tools/misc/git-town/default.nix +++ b/pkgs/tools/misc/git-town/default.nix @@ -1,10 +1,9 @@ -{ lib, buildGoPackage, fetchFromGitHub }: +{ lib, buildGoModule, fetchFromGitHub, installShellFiles, git, testers, git-town, makeWrapper }: -buildGoPackage rec { +buildGoModule rec { pname = "git-town"; version = "7.7.0"; - goPackagePath = "github.com/git-town/git-town"; src = fetchFromGitHub { owner = "git-town"; repo = "git-town"; @@ -12,12 +11,58 @@ buildGoPackage rec { 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; { description = "Generic, high-level git support for git-flow workflows"; homepage = "https://www.git-town.com/"; - maintainers = [ maintainers.allonsy maintainers.blaggacao ]; license = licenses.mit; + maintainers = with maintainers; [ allonsy blaggacao ]; }; }