1{
2 lib,
3 stdenv,
4 fetchzip,
5 python3,
6 librandombytes,
7}:
8
9stdenv.mkDerivation (finalAttrs: {
10 pname = "libcpucycles";
11 version = "20240318";
12
13 src = fetchzip {
14 url = "https://cpucycles.cr.yp.to/libcpucycles-${finalAttrs.version}.tar.gz";
15 hash = "sha256-Fb73EOHGgEehZJwTCtCG12xwyiqtDXFs9eFDsHBQiDo=";
16 };
17
18 patches = [ ./environment-variable-tools.patch ];
19
20 postPatch = ''
21 patchShebangs configure
22 patchShebangs scripts-build
23 '';
24
25 nativeBuildInputs = [ python3 ];
26
27 inherit (librandombytes) hardeningDisable configurePlatforms env;
28
29 preFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
30 install_name_tool -id "$out/lib/libcpucycles.1.dylib" "$out/lib/libcpucycles.1.dylib"
31 install_name_tool -change "libcpucycles.1.dylib" "$out/lib/libcpucycles.1.dylib" "$out/bin/cpucycles-info"
32 '';
33
34 passthru.updateScript = ./update.sh;
35
36 meta = {
37 homepage = "https://cpucycles.cr.yp.to/";
38 description = "Microlibrary for counting CPU cycles";
39 changelog = "https://cpucycles.cr.yp.to/download.html";
40 license = with lib.licenses; [
41 # Upstream specifies the public domain licenses with the terms here https://cr.yp.to/spdx.html
42 publicDomain
43 cc0
44 bsd0
45 mit
46 mit0
47 ];
48 maintainers = with lib.maintainers; [
49 kiike
50 imadnyc
51 jleightcap
52 ];
53 inherit (librandombytes.meta) platforms;
54 };
55})