diff --git a/pkgs/by-name/go/golds/info_module-gover.patch b/pkgs/by-name/go/golds/info_module-gover.patch new file mode 100644 index 000000000000..4b219779336e --- /dev/null +++ b/pkgs/by-name/go/golds/info_module-gover.patch @@ -0,0 +1,25 @@ +diff --git a/internal/server/info_module.go b/internal/server/info_module.go +index d2513bd..ad2921e 100644 +--- a/internal/server/info_module.go ++++ b/internal/server/info_module.go +@@ -8,6 +8,7 @@ import ( + "io/ioutil" + "log" + "os" ++ "os/exec" + "path/filepath" + "regexp" + "strings" +@@ -756,7 +757,11 @@ func findGoToolchainVersionFromGoRoot(goroot string) (string, error) { + versionData, err = ioutil.ReadFile(filepath.Join(goroot, "VERSION.cache")) + } + if err != nil { +- return "", fmt.Errorf("failed to get Go toolchain version in GOROOT (%s)", goroot) ++ cmd := exec.Command("go", "env", "GOVERSION") ++ versionData, err = cmd.Output() ++ if err != nil { ++ return "", fmt.Errorf("failed to get Go toolchain version in GOROOT (%s)", goroot) ++ } + } + matches := findGoVersionRegexp.FindSubmatch(versionData) + if len(matches) >= 1 { diff --git a/pkgs/by-name/go/golds/package.nix b/pkgs/by-name/go/golds/package.nix new file mode 100644 index 000000000000..dee5d2a7b72b --- /dev/null +++ b/pkgs/by-name/go/golds/package.nix @@ -0,0 +1,42 @@ +{ + lib, + buildGoModule, + fetchFromGitHub, + testers, + golds, # self +}: + +buildGoModule rec { + pname = "golds"; + version = "0.7.1"; + + src = fetchFromGitHub { + owner = "go101"; + repo = "golds"; + tag = "v${version}"; + hash = "sha256-6YkyKJtSAFFYidMlZXSjNpjyIIaTlibg/QMMin/NbU0="; + }; + + # nixpkgs is not using the go distpack archive and missing a VERSION file in the source + # but we can use go env to get the same information + # https://github.com/NixOS/nixpkgs/pull/358316#discussion_r1855322027 + patches = [ ./info_module-gover.patch ]; + + vendorHash = "sha256-omjHRZB/4VzPhc6RrFY11s6BRD69+Y4RRZ2XdeKbZf0="; + + ldflags = [ "-s" ]; + + passthru.tests.version = testers.testVersion { + package = golds; + version = "v${version}"; + }; + + meta = { + description = "Experimental Go local docs server/generator and code reader implemented with some fresh ideas"; + homepage = "https://github.com/go101/golds"; + license = lib.licenses.mit; + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ phanirithvij ]; + mainProgram = "golds"; + }; +}