Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 libedit, 6 zlib, 7 ncurses, 8 expect, 9 10}: 11 12stdenv.mkDerivation rec { 13 pname = "kerf"; 14 version = "unstable-2022-08-05"; 15 16 src = fetchFromGitHub { 17 owner = "kevinlawler"; 18 repo = "kerf1"; 19 rev = "4ec5b592b310b96d33654d20d6a511e6fffc0f9d"; 20 hash = "sha256-0sU2zOk5I69lQyrn1g0qsae7S/IBT6eA/911qp0GNkk="; 21 }; 22 23 sourceRoot = "${src.name}/src"; 24 buildInputs = [ 25 libedit 26 zlib 27 ncurses 28 ]; 29 30 nativeCheckInputs = [ expect ]; 31 doCheck = true; 32 33 makeFlags = [ 34 "kerf" 35 "kerf_test" 36 ]; 37 38 # avoid a huge amount of warnings to make failures clearer 39 env.NIX_CFLAGS_COMPILE = toString ( 40 map (x: "-Wno-${x}") [ 41 "void-pointer-to-int-cast" 42 "format" 43 "implicit-function-declaration" 44 "gnu-variable-sized-type-not-at-end" 45 "unused-result" 46 ] 47 ++ lib.optionals stdenv.hostPlatform.isDarwin [ "-fcommon" ] 48 ); 49 50 patchPhase = '' 51 substituteInPlace ./Makefile \ 52 --replace 'CPUS ?=' 'CPUS = $(NIX_BUILD_CORES) #' \ 53 --replace 'termcap' 'ncurses' 54 ''; 55 56 # the kerf executable uses ncurses to create a fancy terminal for input and 57 # reads terminal keystrokes directly, so it doesn't read from stdin as 58 # expected, hence why we use this fancy expect script to run the test exe and 59 # send 'quit' to the prompt after it finishes. 60 checkPhase = '' 61 expect <<EOD 62 set timeout 60 63 spawn ./kerf_test 64 expect { 65 "Passed" {} 66 "Failed" { exit 1 } 67 timeout { exit 1 } 68 } 69 expect { 70 "KeRF> " {send "quit\r"} 71 timeout { exit 1 } 72 } 73 expect { 74 "\[DEBUG\] OK: Done OK." {} 75 "\[DEBUG\] FAILED: Debug failure." { exit 1 } 76 timeout { exit 1 } 77 } 78 exit 0 79 EOD 80 ''; 81 82 installPhase = "install -D kerf $out/bin/kerf"; 83 84 meta = with lib; { 85 description = "Columnar tick database and time-series language"; 86 mainProgram = "kerf"; 87 longDescription = '' 88 Kerf is a columnar tick database and small programming 89 language that is a superset of JSON and SQL. It can be 90 used for local analytics, timeseries, logfile processing, 91 and more. 92 ''; 93 license = with licenses; [ bsd2 ]; 94 homepage = "https://github.com/kevinlawler/kerf1"; 95 platforms = platforms.unix; 96 maintainers = with maintainers; [ thoughtpolice ]; 97 98 # aarch64-linux seems hopeless, with over 2,000 warnings 99 # generated? 100 broken = (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64); 101 }; 102}