nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 meson,
6 ninja,
7 nix-update-script,
8 pkgsBuildBuild,
9 runCommand,
10}:
11
12stdenv.mkDerivation (finalAttrs: {
13 pname = "janet";
14 version = "1.40.1";
15
16 src = fetchFromGitHub {
17 owner = "janet-lang";
18 repo = "janet";
19 rev = "v${finalAttrs.version}";
20 hash = "sha256-BV5hVg85QgN8DXiMF2kA3IQNuvWjcsyciiuQP5+c+7c=";
21 };
22
23 postPatch = ''
24 substituteInPlace janet.1 \
25 --replace /usr/local/ $out/
26 ''
27 + lib.optionalString stdenv.hostPlatform.isDarwin ''
28 # error: Socket is not connected
29 substituteInPlace meson.build \
30 --replace "'test/suite-ev.janet'," ""
31 '';
32
33 depsBuildBuild = [ pkgsBuildBuild.stdenv.cc ];
34 nativeBuildInputs = [
35 meson
36 ninja
37 ];
38
39 mesonBuildType = "release";
40 mesonFlags = [ "-Dgit_hash=release" ];
41
42 doCheck = true;
43
44 doInstallCheck = true;
45
46 installCheckPhase = ''
47 $out/bin/janet -e '(+ 1 2 3)'
48 '';
49
50 passthru = {
51 tests.run =
52 runCommand "janet-test-run"
53 {
54 nativeBuildInputs = [ finalAttrs.finalPackage ];
55 }
56 ''
57 echo "(+ 1 2 3)" | janet | tail -n 1 > arithmeticTest.txt;
58 diff -U3 --color=auto <(cat arithmeticTest.txt) <(echo "6");
59
60 echo "(print \"Hello, World!\")" | janet | tail -n 2 > ioTest.txt;
61 diff -U3 --color=auto <(cat ioTest.txt) <(echo -e "Hello, World!\nnil");
62
63 touch $out;
64 '';
65 updateScript = nix-update-script { };
66 };
67
68 meta = {
69 description = "Janet programming language";
70 mainProgram = "janet";
71 homepage = "https://janet-lang.org/";
72 license = lib.licenses.mit;
73 maintainers = with lib.maintainers; [
74 peterhoeg
75 ];
76 platforms = lib.platforms.all;
77 };
78})