1{ lib
2, buildGoModule
3, fetchgit
4, writeShellScript
5, unstableGitUpdater
6, sd
7}:
8
9buildGoModule rec {
10 pname = "goperf";
11 version = "0-unstable-2024-07-07";
12
13 src = fetchgit {
14 url = "https://go.googlesource.com/perf";
15 rev = "dc66afd55b77cd4e555203ff2c0d3e4d219a1410";
16 hash = "sha256-necbttrRRVcbe4JOFBFNvAl2CPOXe8bC7qPLb8qXJSE=";
17 };
18
19 vendorHash = "sha256-LJ8eNjOufTvLj1939nYkQOi84ZlT8zSGnTztcEKigfY=";
20
21 passthru.updateScript = writeShellScript "update-goperf" ''
22 export UPDATE_NIX_ATTR_PATH=goperf
23 ${lib.escapeShellArgs (unstableGitUpdater { inherit (src) url; })}
24 set -x
25 oldhash="$(nix-instantiate . --eval --strict -A "goperf.goModules.drvAttrs.outputHash" | cut -d'"' -f2)"
26 newhash="$(nix-build -A goperf.goModules --no-out-link 2>&1 | tail -n3 | grep 'got:' | cut -d: -f2- | xargs echo || true)"
27 fname="$(nix-instantiate --eval -E 'with import ./. {}; (builtins.unsafeGetAttrPos "version" goperf).file' | cut -d'"' -f2)"
28 ${lib.getExe sd} --string-mode "$oldhash" "$newhash" "$fname"
29 '';
30
31 meta = with lib; {
32 description = "Tools and packages for analyzing Go benchmark results";
33 homepage = "https://cs.opensource.google/go/x/perf";
34 license = licenses.bsd3;
35 platforms = platforms.all;
36 maintainers = with maintainers; [ pbsds ];
37 };
38}