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