enry: init at 1.3.0

authored by Diogo Correia and committed by Diogo Correia 5b2aee74 05c1ad5d

+57
+57
pkgs/by-name/en/enry/package.nix
··· 1 + { 2 + lib, 3 + buildGoModule, 4 + fetchFromGitHub, 5 + versionCheckHook, 6 + writeScript, 7 + }: 8 + 9 + let 10 + commitHash = "f10711437bfbb25b15506eb69dde24bb7decd222"; # matches tag release 11 + in 12 + buildGoModule (finalAttrs: { 13 + pname = "enry"; 14 + version = "1.3.0"; 15 + 16 + src = fetchFromGitHub { 17 + owner = "go-enry"; 18 + repo = "enry"; 19 + tag = "v${finalAttrs.version}"; 20 + hash = "sha256-JSYOCdWZnCM4Kq3EFkS7XZ5n0ahkR+A8omI4z1S45z8="; 21 + }; 22 + 23 + vendorHash = "sha256-tUDhpeXlKpo1jnNyk0U3CcXroOlv7lHVUxc1wAnysG4="; 24 + 25 + ldflags = [ 26 + "-X main.version=${finalAttrs.version}" 27 + "-X main.commit=${commitHash}" 28 + ]; 29 + 30 + nativeInstallCheckInputs = [ versionCheckHook ]; 31 + doInstallCheck = true; 32 + 33 + passthru.updateScript = writeScript "update-enry" '' 34 + #!/usr/bin/env nix-shell 35 + #!nix-shell -i bash -p curl jq nix-update 36 + 37 + set -eu -o pipefail 38 + 39 + gh_metadata="$(curl -sS https://api.github.com/repos/go-enry/enry/tags)" 40 + version="$(echo "$gh_metadata" | jq -r '.[] | .name' | sort --version-sort | tail -1)" 41 + commit_hash="$(echo "$gh_metadata" | jq -r --arg ver "$version" '.[] | select(.name == $ver).commit.sha')" 42 + 43 + filename="$(nix-instantiate --eval -E "with import ./. {}; (builtins.unsafeGetAttrPos \"version\" enry).file" | tr -d '"')" 44 + sed -i "s/commitHash = \"[^\"]*\"/commitHash = \"$commit_hash\"/" $filename 45 + 46 + nix-update enry 47 + ''; 48 + 49 + meta = { 50 + description = "Programming language detector based on go-enry/go-enry/v2 library"; 51 + mainProgram = "enry"; 52 + homepage = "https://github.com/go-enry/enry"; 53 + changelog = "https://github.com/go-enry/enry/releases/tag/v${finalAttrs.version}"; 54 + license = lib.licenses.asl20; 55 + maintainers = with lib.maintainers; [ dvcorreia ]; 56 + }; 57 + })