1{
2 lib,
3 stdenvNoCC,
4 stdenv, # for tests
5 fetchFromGitHub,
6}:
7
8stdenvNoCC.mkDerivation (finalAttrs: {
9 pname = "pdqsort";
10 version = "0-unstable-2021-03-14";
11
12 src = fetchFromGitHub {
13 owner = "orlp";
14 repo = "pdqsort";
15 rev = "b1ef26a55cdb60d236a5cb199c4234c704f46726";
16 hash = "sha256-xn3Jjn/jxJBckpg1Tx3HHVAWYPVTFMiDFiYgB2WX7Sc=";
17 };
18
19 installPhase = ''
20 runHook preInstall
21
22 mkdir -p $out/include
23 cp -r *.h $out/include/
24
25 runHook postInstall
26 '';
27
28 # The benchmark takes too long to run as a regular checkPhase here.
29 passthru.tests.bench = stdenv.mkDerivation {
30 pname = "pdqsort-bench";
31
32 inherit (finalAttrs) version src;
33
34 doCheck = true;
35 checkPhase = ''
36 c++ bench/bench.cpp -o bench/bench
37 ./bench/bench > $out
38 '';
39
40 meta.platforms = lib.platforms.x86_64;
41 };
42
43 meta = {
44 description = "Novel sorting algorithm that combines the fast average case of randomized quicksort with the fast worst case of heapsort";
45 homepage = "https://github.com/orlp/pdqsort";
46 license = lib.licenses.zlib;
47 maintainers = with lib.maintainers; [ jherland ];
48 };
49})