nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchzip,
5 fetchpatch,
6}:
7
8stdenv.mkDerivation rec {
9 pname = "miranda";
10 version = "2.066";
11
12 # The build generates object files (`.x`) from module files (`.m`).
13 # To be able to invalidate object file, it contains the `mtime`
14 # of the corresponding module file at the time of the build.
15 # When a file is installed to Nix store its `mtime` is set to `1`,
16 # so the `mtime` field in the object file would no longer match
17 # and Miranda would try to regenerate it at the runtime,
18 # even though it is up to date.
19 # Using `fetchzip` will make all the source files have `mtime=1`
20 # from the start so this mismatch cannot occur.
21 src = fetchzip {
22 url = "https://www.cs.kent.ac.uk/people/staff/dat/miranda/src/mira-${
23 builtins.replaceStrings [ "." ] [ "" ] version
24 }-src.tgz";
25 sha256 = "KE/FTL9YW9l7VBAgkFZlqgSM1Bt/BXT6GkkONtyKJjQ=";
26 };
27
28 patches = [
29 # Allow passing `PREFIX` to makeFlags.
30 # Sent upstream on 2020-10-10.
31 (fetchpatch {
32 name = "fix-makefile-variables.patch";
33 url = "https://github.com/jtojnar/miranda/commit/be62d2150725a4c314aa7e3e1e75a165c90be65d.patch";
34 sha256 = "0r8nnr7iyzp1a3w3n6y1xi0ralqhm1ifp75yhyj3h1g229vk51a6";
35 })
36
37 # Create the installation directories.
38 # Sent upstream on 2020-10-10.
39 (fetchpatch {
40 name = "add-mkdirs-makefile.patch";
41 url = "https://github.com/jtojnar/miranda/commit/048754606625975d5358e946549c41ae7b5d3428.patch";
42 sha256 = "1n8xv679i7s789km2dxxrs2pphyyi7vr7rhafqvmkcdmhmxk9h2a";
43 })
44
45 # Use correct installation path for finding the library.
46 # Sent upstream on 2020-10-10.
47 (fetchpatch {
48 name = "c-path-fixes.patch";
49 url = "https://github.com/jtojnar/miranda/commit/aea0a118a802a0da6029b781f7cfd388224263cf.patch";
50 sha256 = "1z3giv8fzc35a23ga9ahz9d1fbvya67kavnb8h4rv2icbzr5j5gd";
51 })
52
53 # Make build reproducible.
54 # Sent upstream on 2020-10-10.
55 (fetchpatch {
56 name = "deterministic-build.patch";
57 url = "https://github.com/jtojnar/miranda/commit/daf8abb8f30ec1cca21698e3fc355578b9f7c571.patch";
58 sha256 = "TC/YrHrMzdlwicJ3oJ/TjwhkufmV3ypemgyqhMmVut4=";
59 })
60 ];
61
62 # Workaround build failure on -fno-common toolchains like upstream
63 # gcc-10. Otherwise build fails as:
64 # ld: types.o:(.bss+0x11b0): multiple definition of `current_file'; y.tab.o:(.bss+0x70): first defined here
65 env.NIX_CFLAGS_COMPILE = toString (
66 [
67 "-fcommon"
68 ]
69 ++ lib.optionals stdenv.cc.isClang [
70 "-Wno-error=int-conversion"
71 ]
72 );
73
74 makeFlags = [
75 "CC=${stdenv.cc.targetPrefix}cc"
76 "CFLAGS=-O2"
77 "PREFIX=${placeholder "out"}"
78 ];
79
80 enableParallelBuilding = true;
81
82 postPatch = ''
83 patchShebangs quotehostinfo
84 substituteInPlace Makefile --replace strip '${stdenv.cc.targetPrefix}strip'
85 '';
86
87 meta = {
88 description = "Compiler for Miranda -- a pure, non-strict, polymorphic, higher order functional programming language";
89 homepage = "https://www.cs.kent.ac.uk/people/staff/dat/miranda/";
90 license = lib.licenses.bsd2;
91 maintainers = with lib.maintainers; [ siraben ];
92 platforms = lib.platforms.all;
93 mainProgram = "mira";
94 };
95}