1{
2 binutils,
3 fetchurl,
4 gcc,
5 lib,
6 runCommand,
7 stdenv,
8}:
9
10stdenv.mkDerivation (finalAttrs: {
11 pname = "clean";
12 version = "3.1";
13
14 src =
15 if stdenv.hostPlatform.system == "i686-linux" then
16 (fetchurl {
17 url = "https://ftp.cs.ru.nl/Clean/Clean31/linux/clean3.1_32_boot.tar.gz";
18 sha256 = "Ls0IKf+o7yhRLhtSV61jzmnYukfh5x5fogHaP5ke/Ck=";
19 })
20 else if stdenv.hostPlatform.system == "x86_64-linux" then
21 (fetchurl {
22 url = "https://ftp.cs.ru.nl/Clean/Clean31/linux/clean3.1_64_boot.tar.gz";
23 sha256 = "Gg5CVZjrwDBtV7Vuw21Xj6Rn+qN1Mf6B3ls6r/16oBc=";
24 })
25 else
26 throw "Architecture not supported";
27
28 hardeningDisable = [ "pic" ];
29
30 patches = [
31 ./chroot-build-support-do-not-rebuild-equal-timestamps.patch
32 ./declare-functions-explicitly-for-gcc14.patch
33 ];
34
35 postPatch = ''
36 substituteInPlace Makefile \
37 --replace-fail 'INSTALL_DIR = $(CURRENTDIR)' "INSTALL_DIR = $out"
38 substituteInPlace src/clm/clm.c \
39 --replace-fail /usr/bin/as ${binutils}/bin/as \
40 --replace-fail /usr/bin/gcc ${gcc}/bin/gcc
41 '';
42
43 buildFlags = [ "-C src/" ];
44
45 # do not strip libraries and executables since all symbols since they are
46 # required as is for compilation. Especially the labels of unused section need
47 # to be kept.
48 dontStrip = true;
49
50 passthru.tests.compile-hello-world = runCommand "compile-hello-world" { } ''
51 cat >HelloWorld.icl <<EOF
52 module HelloWorld
53 Start = "Hello, world!"
54 EOF
55 ${finalAttrs.finalPackage}/bin/clm HelloWorld -o hello-world
56 touch $out
57 '';
58
59 meta = {
60 description = "General purpose, state-of-the-art, pure and lazy functional programming language";
61 longDescription = ''
62 Clean is a general purpose, state-of-the-art, pure and lazy functional
63 programming language designed for making real-world applications. Some
64 of its most notable language features are uniqueness typing, dynamic typing,
65 and generic functions.
66 '';
67
68 homepage = "http://wiki.clean.cs.ru.nl/Clean";
69 license = lib.licenses.bsd2;
70 maintainers = with lib.maintainers; [
71 bmrips
72 erin
73 ];
74 platforms = [
75 "i686-linux"
76 "x86_64-linux"
77 ];
78 mainProgram = "clean";
79 };
80})