summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/li/libcpucycles/package.nix
blob: c1c5f1a24a8d6e281d1f5006a900637683745980 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
  lib,
  stdenv,
  fetchzip,
  python3,
  librandombytes,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "libcpucycles";
  version = "20260105";

  src = fetchzip {
    url = "https://cpucycles.cr.yp.to/libcpucycles-${finalAttrs.version}.tar.gz";
    hash = "sha256-hWmMLBadM/E/kF8D/cTjU+G0f2HTkZQlKoIWsgzAFj0=";
  };

  patches = [ ./environment-variable-tools.patch ];

  postPatch = ''
    patchShebangs configure
    patchShebangs scripts-build
  '';

  nativeBuildInputs = [ python3 ];

  inherit (librandombytes) hardeningDisable configurePlatforms env;

  preFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
    install_name_tool -id "$out/lib/libcpucycles.1.dylib" "$out/lib/libcpucycles.1.dylib"
    install_name_tool -change "libcpucycles.1.dylib" "$out/lib/libcpucycles.1.dylib" "$out/bin/cpucycles-info"
  '';

  passthru.updateScript = ./update.sh;

  meta = {
    homepage = "https://cpucycles.cr.yp.to/";
    description = "Microlibrary for counting CPU cycles";
    changelog = "https://cpucycles.cr.yp.to/download.html";
    license =
      # Upstream specifies the public domain licenses with the terms here https://cpucycles.cr.yp.to/license.html
      lib.licenses.OR [
        lib.licenses.publicDomain
        lib.licenses.cc0
        lib.licenses.bsd0
        lib.licenses.mit
        lib.licenses.mit0
      ];
    maintainers = with lib.maintainers; [
      kiike
      imadnyc
      jleightcap
    ];
    inherit (librandombytes.meta) platforms;
  };
})