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