From 3524da2f0ab911c9c65ac6fb34e87b9698a4e5fb Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Fri, 5 Aug 2022 17:03:05 -0500 Subject: [PATCH] kerf_1: init at unstable-2022-08-05 Signed-off-by: Austin Seipp --- .../development/interpreters/kerf/default.nix | 92 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 8 ++ 2 files changed, 100 insertions(+) create mode 100644 pkgs/development/interpreters/kerf/default.nix diff --git a/pkgs/development/interpreters/kerf/default.nix b/pkgs/development/interpreters/kerf/default.nix new file mode 100644 index 000000000000..5b605c6564b3 --- /dev/null +++ b/pkgs/development/interpreters/kerf/default.nix @@ -0,0 +1,92 @@ +{ lib, stdenv, fetchFromGitHub +, libedit, zlib, ncurses, expect + +# darwin only below +, Accelerate, CoreGraphics, CoreVideo +}: + +stdenv.mkDerivation rec { + pname = "kerf"; + version = "unstable-2022-08-05"; + + src = fetchFromGitHub { + owner = "kevinlawler"; + repo = "kerf1"; + rev = "4ec5b592b310b96d33654d20d6a511e6fffc0f9d"; + hash = "sha256-0sU2zOk5I69lQyrn1g0qsae7S/IBT6eA/911qp0GNkk="; + }; + + sourceRoot = "source/src"; + buildInputs = [ libedit zlib ncurses ] + ++ lib.optional stdenv.isDarwin ([ + Accelerate + ] ++ lib.optional stdenv.isx86_64 /* && isDarwin */ [ + CoreGraphics CoreVideo + ]); + + checkInputs = [ expect ]; + doCheck = true; + + makeFlags = [ "kerf" "kerf_test" ]; + + # avoid a huge amount of warnings to make failures clearer + NIX_CFLAGS_COMPILE = map (x: "-Wno-${x}") [ + "void-pointer-to-int-cast" + "format" + "implicit-function-declaration" + "gnu-variable-sized-type-not-at-end" + "unused-result" + ] ++ lib.optional stdenv.isDarwin [ "-fcommon" ]; + + patchPhase = '' + substituteInPlace ./Makefile \ + --replace 'CPUS ?=' 'CPUS = $(NIX_BUILD_CORES) #' \ + --replace 'termcap' 'ncurses' + ''; + + # the kerf executable uses ncurses to create a fancy terminal for input and + # reads terminal keystrokes directly, so it doesn't read from stdin as + # expected, hence why we use this fancy expect script to run the test exe and + # send 'quit' to the prompt after it finishes. + checkPhase = '' + expect < " {send "quit\r"} + timeout { exit 1 } + } + expect { + "\[DEBUG\] OK: Done OK." {} + "\[DEBUG\] FAILED: Debug failure." { exit 1 } + timeout { exit 1 } + } + exit 0 + EOD + ''; + + installPhase = "install -D kerf $out/bin/kerf"; + + meta = with lib; { + description = "Columnar tick database and time-series language"; + longDescription = '' + Kerf is a columnar tick database and small programming + language that is a superset of JSON and SQL. It can be + used for local analytics, timeseries, logfile processing, + and more. + ''; + license = with licenses; [ bsd2 ]; + homepage = "https://github.com/kevinlawler/kerf1"; + platforms = platforms.unix; + maintainers = with maintainers; [ thoughtpolice ]; + + # aarch64-linux seems hopeless, with over 2,000 warnings + # generated? + broken = (stdenv.isLinux && stdenv.isAarch64); + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 21979f95ba29..2e6a1a37376a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2639,6 +2639,14 @@ with pkgs; goku = callPackage ../os-specific/darwin/goku { }; + kerf = kerf_1; /* kerf2 is WIP */ + kerf_1 = callPackage ../development/interpreters/kerf { + stdenv = clangStdenv; + inherit (darwin.apple_sdk.frameworks) + Accelerate CoreGraphics CoreVideo + ; + }; + kwakd = callPackage ../servers/kwakd { }; kwm = callPackage ../os-specific/darwin/kwm { };