nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 makeWrapper,
6 pandoc,
7 installShellFiles,
8 perl,
9 libxext,
10 libx11,
11 x11perf,
12 libGLX,
13 coreutils,
14 unixtools,
15 runtimeShell,
16 targetPackages,
17 gnugrep,
18 gawk,
19 withGL ? true,
20 withX11perf ? true,
21}:
22
23stdenv.mkDerivation rec {
24 pname = "unixbench";
25 version = "unstable-2023-02-27";
26
27 src = fetchFromGitHub {
28 owner = "kdlucas";
29 repo = "byte-unixbench";
30 rev = "a07fcc03264915c624f0e4818993c5b4df3fa703";
31 hash = "sha256-gmRWAqE9/HBb0S9rK0DXoaCoiGbtat0gmdeozhbv0NI=";
32 };
33
34 patches = [
35 ./common.patch
36 ];
37
38 patchFlags = [ "-p2" ];
39
40 sourceRoot = "${src.name}/UnixBench";
41
42 postPatch = ''
43 substituteInPlace Makefile \
44 --replace "-Wa,-q" ""
45 '';
46
47 nativeBuildInputs = [
48 makeWrapper
49 pandoc
50 installShellFiles
51 ];
52
53 buildInputs = [
54 perl
55 ]
56 ++ lib.optionals withGL [
57 libx11
58 libxext
59 libGLX
60 ];
61
62 runtimeDependencies = [
63 coreutils
64 unixtools.net-tools
65 unixtools.locale
66 targetPackages.stdenv.cc
67 gnugrep
68 gawk
69 ]
70 ++ lib.optionals withX11perf [
71 x11perf
72 ];
73
74 makeFlags = [
75 "CC=${stdenv.cc.targetPrefix}cc"
76 ]
77 ++ lib.optionals withGL [
78 "GRAPHIC_TESTS=defined"
79 ];
80
81 installPhase = ''
82 runHook preInstall
83 mkdir -p $out/{bin,libexec,share}
84 install -D Run $out/bin/ubench
85 cp -r pgms $out/libexec/
86 cp -r testdir $out/share/
87 runHook postInstall
88 '';
89
90 postInstall = ''
91 substituteInPlace USAGE \
92 --replace 'Run"' 'ubench"' \
93 --replace './Run' 'ubench' \
94 --replace 'Run ' 'ubench '
95 pandoc -f rst -t man USAGE -o ubench.1
96 installManPage ubench.1
97 '';
98
99 preFixup = ''
100 substituteInPlace $out/libexec/pgms/multi.sh \
101 --replace '/bin/sh "$' '${runtimeShell} "$'
102
103 substituteInPlace $out/bin/ubench \
104 --subst-var out
105
106 wrapProgram $out/bin/ubench \
107 --prefix PATH : ${lib.makeBinPath runtimeDependencies}
108 '';
109
110 meta = {
111 description = "Basic indicator of the performance of a Unix-like system";
112 homepage = "https://github.com/kdlucas/byte-unixbench";
113 license = lib.licenses.gpl2Plus;
114 mainProgram = "ubench";
115 maintainers = with lib.maintainers; [ aleksana ];
116 platforms = lib.platforms.unix;
117 };
118}