From 3cbfe5c47b18883d0ff127c69dfe69bab19fd4ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20N=C3=BCtzi?= Date: Tue, 23 Apr 2024 01:10:18 +0200 Subject: [PATCH] githooks: init at 3.0.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add platform-independent Git hooks manager `Githooks` at version 3.0.1.Check the [Readme](https://github.com/gabyx/Githooks) for moreinformation. Signed-off-by: Gabriel Nützi --- pkgs/by-name/gi/githooks/package.nix | 85 ++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 pkgs/by-name/gi/githooks/package.nix diff --git a/pkgs/by-name/gi/githooks/package.nix b/pkgs/by-name/gi/githooks/package.nix new file mode 100644 index 000000000000..349e5db06445 --- /dev/null +++ b/pkgs/by-name/gi/githooks/package.nix @@ -0,0 +1,85 @@ +{ + lib, + buildGoModule, + fetchFromGitHub, + git, + testers, + makeWrapper, +}: +buildGoModule rec { + pname = "githooks"; + version = "3.0.1"; + + src = fetchFromGitHub { + owner = "gabyx"; + repo = "githooks"; + rev = "v${version}"; + hash = "sha256-qv0nl3EEYVo/s79r+yK3ZQCGPXM2bzGdWatPY24aOZg="; + }; + + modRoot = "./githooks"; + vendorHash = "sha256-ZcDD4Z/thtyCvXg6GzzKC/FSbh700QEaqXU8FaZaZc4="; + + nativeBuildInputs = [ makeWrapper ]; + + buildInputs = [ git ]; + + strictDeps = true; + + ldflags = [ + "-s" # Disable symbole table. + "-w" # Disable DWARF generation. + ]; + + # We need to disable updates and other features: + # That is done with tag `package_manager_enabled`. + tags = [ "package_manager_enabled" ]; + + checkFlags = + let + skippedTests = [ + "TestGithooksCompliesWithGit" # Needs internet to download all hooks documentation. + "TestUpdateImages" # Needs docker/podman. + ]; + in + [ + "-v" + "-skip" + "(${builtins.concatStringsSep "|" skippedTests})" + ]; + + doCheck = true; + + # We need to generate some build files before building. + postConfigure = '' + GH_BUILD_VERSION="${version}" \ + GH_BUILD_TAG="v${version}" \ + go generate -mod=vendor ./... + ''; + + postInstall = '' + # Rename executable to proper names. + mv $out/bin/cli $out/bin/githooks-cli + mv $out/bin/runner $out/bin/githooks-runner + mv $out/bin/dialog $out/bin/githooks-dialog + ''; + + postFixup = '' + wrapProgram "$out/bin/githooks-cli" --prefix PATH : ${lib.makeBinPath [ git ]} + wrapProgram "$out/bin/githooks-runner" --prefix PATH : ${lib.makeBinPath [ git ]} + ''; + + passthru.tests.version = testers.testVersion { + package = "githooks-cli"; + command = "githooks-cli --version"; + inherit version; + }; + + meta = with lib; { + description = "A Git hooks manager with per-repo and shared Git hooks including version control"; + homepage = "https://github.com/gabyx/Githooks"; + license = licenses.mpl20; + maintainers = with maintainers; [ gabyx ]; + mainProgram = "githooks-cli"; + }; +}