Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, fetchgit 4, fetchurl 5, libuuid 6, makeWrapper 7, mtools 8, nasm 9, perl 10, python3 11}: 12 13stdenv.mkDerivation { 14 pname = "syslinux"; 15 version = "unstable-2019-02-07"; 16 17 # This is syslinux-6.04-pre3^1; syslinux-6.04-pre3 fails to run. 18 # Same issue here https://www.syslinux.org/archives/2019-February/026330.html 19 src = fetchgit { 20 url = "https://repo.or.cz/syslinux"; 21 rev = "b40487005223a78c3bb4c300ef6c436b3f6ec1f7"; 22 sha256 = "sha256-GqvRTr9mA2yRD0G0CF11x1X0jCgqV4Mh+tvE0/0yjqk="; 23 fetchSubmodules = true; 24 }; 25 26 patches = let 27 fetchDebianPatch = name: commit: hash: 28 fetchurl { 29 url = "https://salsa.debian.org/images-team/syslinux/raw/" 30 + commit + "/debian/patches/" + name; 31 inherit name hash; 32 }; 33 fetchArchlinuxPatch = name: commit: hash: 34 fetchurl { 35 url = "https://raw.githubusercontent.com/archlinux/svntogit-packages/" 36 + commit + "/trunk/" + name; 37 inherit name hash; 38 }; 39 in [ 40 ./gcc10.patch 41 (fetchDebianPatch 42 "0002-gfxboot-menu-label.patch" 43 "fa1349f1" 44 "sha256-0f6QhM4lJmGflLige4n7AZTodL7vnyAvi5dIedd/Lho=") 45 (fetchArchlinuxPatch 46 "0005-gnu-efi-version-compatibility.patch" 47 "821c3da473d1399d930d5b4a086e46a4179eaa45" 48 "sha256-hhCVnfbAFWj/R4yh60qsMB87ofW9RznarsByhl6L4tc=") 49 (fetchArchlinuxPatch 50 "0025-reproducible-build.patch" 51 "821c3da473d1399d930d5b4a086e46a4179eaa45" 52 "sha256-mnb291pCSFvDNxY7o4BosJ94ib3BpOGRQIiY8Q3jZmI=") 53 (fetchDebianPatch 54 # mbr.bin: too big (452 > 440) 55 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=906414 56 "0016-strip-gnu-property.patch" 57 "7468ef0e38c43" 58 "sha256-lW+E6THuXlTGvhly0f/D9NwYHhkiKHot2l+bz9Eaxp4=") 59 (fetchDebianPatch 60 # mbr.bin: too big (452 > 440) 61 "0017-single-load-segment.patch" 62 "012e1dd312eb" 63 "sha256-C6VmdlTs1blMGUHH3OfOlFBZsfpwRn9vWodwqVn8+Cs=") 64 (fetchDebianPatch 65 "0018-prevent-pow-optimization.patch" 66 "26f0e7b2" 67 "sha256-dVzXBi/oSV9vYgU85mRFHBKuZdup+1x1BipJX74ED7E=") 68 ]; 69 70 postPatch = '' 71 substituteInPlace Makefile --replace /bin/pwd $(type -P pwd) 72 substituteInPlace utils/ppmtolss16 --replace /usr/bin/perl $(type -P perl) 73 74 # fix tests 75 substituteInPlace tests/unittest/include/unittest/unittest.h \ 76 --replace /usr/include/ "" 77 78 # Hack to get `gcc -m32' to work without having 32-bit Glibc headers. 79 mkdir gnu-efi/inc/ia32/gnu 80 touch gnu-efi/inc/ia32/gnu/stubs-32.h 81 ''; 82 83 nativeBuildInputs = [ 84 nasm 85 perl 86 python3 87 makeWrapper 88 ]; 89 90 buildInputs = [ 91 libuuid 92 ]; 93 94 # Fails very rarely with 'No rule to make target: ...' 95 enableParallelBuilding = false; 96 97 hardeningDisable = [ "pic" "stackprotector" "fortify" ]; 98 99 stripDebugList = [ "bin" "sbin" "share/syslinux/com32" ]; 100 101 # Workaround build failure on -fno-common toolchains like upstream 102 # gcc-10. Otherwise build fails as: 103 # ld: acpi/xsdt.o:/build/syslinux-b404870/com32/gpllib/../gplinclude/memory.h:40: multiple definition of 104 # `e820_types'; memory.o:/build/syslinux-b404870/com32/gpllib/../gplinclude/memory.h:40: first defined here 105 env.NIX_CFLAGS_COMPILE = "-fcommon"; 106 107 makeFlags = [ 108 "BINDIR=$(out)/bin" 109 "SBINDIR=$(out)/sbin" 110 "DATADIR=$(out)/share" 111 "MANDIR=$(out)/share/man" 112 "PERL=perl" 113 "HEXDATE=0x00000000" 114 ] 115 ++ lib.optionals stdenv.hostPlatform.isi686 [ "bios" "efi32" ]; 116 117 # Some tests require qemu, some others fail in a sandboxed environment 118 doCheck = false; 119 120 postInstall = '' 121 wrapProgram $out/bin/syslinux \ 122 --prefix PATH : "${mtools}/bin" 123 124 # Delete com32 headers to save space, nobody seems to be using them 125 rm -rf $out/share/syslinux/com32 126 ''; 127 128 meta = with lib; { 129 homepage = "http://www.syslinux.org/"; 130 description = "A lightweight bootloader"; 131 license = licenses.gpl2Plus; 132 maintainers = [ maintainers.samueldr ]; 133 platforms = [ "i686-linux" "x86_64-linux" ]; 134 }; 135}