1{ lib, stdenv, stdenv_32bit, pkgsi686Linux, fetchFromGitHub, fetchurl }:
2
3stdenv.mkDerivation rec {
4 pname = "red";
5 version = "0.6.4";
6 src = fetchFromGitHub {
7 rev = "755eb943ccea9e78c2cab0f20b313a52404355cb";
8 owner = "red";
9 repo = "red";
10 sha256 = "sha256:045rrg9666zczgrwyyyglivzdzja103s52b0fzj7hqmr1fz68q37";
11 };
12
13 rebol = fetchurl {
14 url = "http://www.rebol.com/downloads/v278/rebol-core-278-4-2.tar.gz";
15 sha256 = "1c1v0pyhf3d8z98qc93a5zmx0bbl0qq5lr8mbkdgygqsq2bv2xbz";
16 };
17
18 buildInputs = [ pkgsi686Linux.curl stdenv_32bit ];
19
20 r2 = "./rebol/releases/rebol-core/rebol";
21
22 configurePhase = ''
23 # Download rebol
24 mkdir rebol/
25 tar -xzvf ${rebol} -C rebol/
26 patchelf --set-interpreter \
27 ${stdenv_32bit.cc.libc.out}/lib/32/ld-linux.so.2 \
28 ${r2}
29 '';
30
31 buildPhase = ''
32 # Do tests
33 #${r2} -qw run-all.r
34
35 # Build test
36 ${r2} -qw red.r tests/hello.red
37
38 # Compiling the Red console...
39 ${r2} -qw red.r -r environment/console/CLI/console.red
40
41 # Generating docs...
42 cd docs
43 ../${r2} -qw makedoc2.r red-system-specs.txt
44 ../${r2} -qw makedoc2.r red-system-quick-test.txt
45 cd ../
46 '';
47
48 installPhase = ''
49 mkdir $out
50
51 # Install
52 install -d $out/opt/red
53 find quick-test -type f -executable -print0 | xargs -0 rm
54 cp -R * $out/opt/red/
55 rm -rf $out/opt/red/rebol
56 install -Dm755 console $out/bin/red
57 install -Dm644 BSD-3-License.txt \
58 $out/share/licenses/${pname}-${version}/BSD-3-License.txt
59 install -Dm644 BSL-License.txt \
60 $out/share/licenses/${pname}-${version}/BSL-License.txt
61 install -Dm644 docs/red-system-quick-test.html \
62 $out/share/doc/${pname}-${version}/red-system-quick-test.html
63 install -Dm644 docs/red-system-specs.html \
64 $out/share/doc/${pname}-${version}/red-system-specs.html
65
66 # PathElf
67 patchelf --set-interpreter \
68 ${stdenv_32bit.cc.libc.out}/lib/32/ld-linux.so.2 \
69 $out/opt/red/console
70 patchelf --set-rpath ${pkgsi686Linux.curl.out}/lib \
71 $out/opt/red/console
72 patchelf --set-interpreter \
73 ${stdenv_32bit.cc.libc.out}/lib/32/ld-linux.so.2 \
74 $out/bin/red
75 patchelf --set-rpath ${pkgsi686Linux.curl.out}/lib \
76 $out/bin/red
77
78 '';
79
80 meta = with lib; {
81 description = ''
82 New programming language strongly inspired by Rebol, but with a
83 broader field of usage thanks to its native-code compiler, from system
84 programming to high-level scripting, while providing modern support for
85 concurrency and multi-core CPUs
86 '';
87 maintainers = with maintainers; [ uralbash ];
88 platforms = [ "i686-linux" "x86_64-linux" ];
89 license = licenses.bsd3;
90 homepage = "https://www.red-lang.org/";
91 };
92}