2023-11-16 04:20:00 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, meson
|
|
|
|
, ninja
|
|
|
|
, nix-update-script
|
|
|
|
, runCommand
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "janet";
|
2024-09-26 11:04:55 +00:00
|
|
|
version = "1.36.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "janet-lang";
|
2023-11-16 04:20:00 +00:00
|
|
|
repo = "janet";
|
|
|
|
rev = "v${finalAttrs.version}";
|
2024-09-26 11:04:55 +00:00
|
|
|
hash = "sha256-lAasSRQwqkc86jobSejLFGAiaCu+EM+2sc92Kc2KxMs=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-02-20 05:27:41 +00:00
|
|
|
postPatch = ''
|
2021-07-14 22:03:04 +00:00
|
|
|
substituteInPlace janet.1 \
|
2022-02-20 05:27:41 +00:00
|
|
|
--replace /usr/local/ $out/
|
2024-09-26 11:04:55 +00:00
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
|
2023-11-16 04:20:00 +00:00
|
|
|
# error: Socket is not connected
|
|
|
|
substituteInPlace meson.build \
|
|
|
|
--replace "'test/suite-ev.janet'," ""
|
2021-07-14 22:03:04 +00:00
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [ meson ninja ];
|
2021-07-14 22:03:04 +00:00
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
mesonBuildType = "release";
|
2020-04-24 23:36:52 +00:00
|
|
|
mesonFlags = [ "-Dgit_hash=release" ];
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
|
|
|
|
installCheckPhase = ''
|
2022-09-22 12:36:57 +00:00
|
|
|
$out/bin/janet -e '(+ 1 2 3)'
|
2022-07-14 12:49:19 +00:00
|
|
|
'';
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
passthru = {
|
|
|
|
tests.run = runCommand "janet-test-run" {
|
|
|
|
nativeBuildInputs = [finalAttrs.finalPackage];
|
|
|
|
} ''
|
|
|
|
echo "(+ 1 2 3)" | janet | tail -n 1 > arithmeticTest.txt;
|
|
|
|
diff -U3 --color=auto <(cat arithmeticTest.txt) <(echo "6");
|
|
|
|
|
|
|
|
echo "(print \"Hello, World!\")" | janet | tail -n 2 > ioTest.txt;
|
|
|
|
diff -U3 --color=auto <(cat ioTest.txt) <(echo -e "Hello, World!\nnil");
|
|
|
|
|
|
|
|
touch $out;
|
|
|
|
'';
|
|
|
|
updateScript = nix-update-script {};
|
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Janet programming language";
|
2024-04-21 15:54:59 +00:00
|
|
|
mainProgram = "janet";
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://janet-lang.org/";
|
|
|
|
license = licenses.mit;
|
2021-07-14 22:03:04 +00:00
|
|
|
maintainers = with maintainers; [ andrewchambers peterhoeg ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
2023-11-16 04:20:00 +00:00
|
|
|
})
|