nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 184 lines 5.4 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 gnu-efi_3, 6 nixosTests, 7 efibootmgr, 8 openssl, 9 withSbsigntool ? false, # currently, cross compiling sbsigntool is broken, so default to false 10 sbsigntool, 11 makeWrapper, 12}: 13 14let 15 archids = { 16 x86_64-linux = { 17 hostarch = "x86_64"; 18 efiPlatform = "x64"; 19 }; 20 i686-linux = rec { 21 hostarch = "ia32"; 22 efiPlatform = hostarch; 23 }; 24 aarch64-linux = { 25 hostarch = "aarch64"; 26 efiPlatform = "aa64"; 27 }; 28 }; 29 30 inherit 31 (archids.${stdenv.hostPlatform.system} 32 or (throw "unsupported system: ${stdenv.hostPlatform.system}") 33 ) 34 hostarch 35 efiPlatform 36 ; 37in 38 39stdenv.mkDerivation rec { 40 pname = "refind"; 41 version = "0.14.2"; 42 43 src = fetchurl { 44 url = "mirror://sourceforge/project/refind/${version}/refind-src-${version}.tar.gz"; 45 hash = "sha256-99k86A2na4bFZygeoiW2qHkHzob/dyM8k1elIsEVyPA="; 46 }; 47 48 patches = [ 49 # Removes hardcoded toolchain for aarch64, allowing successful aarch64 builds. 50 ./0001-toolchain.patch 51 # Avoid leaking the build timestamp 52 # https://sourceforge.net/p/refind/code/merge-requests/53/ 53 ./0002-preserve-dates.patch 54 ]; 55 56 nativeBuildInputs = [ makeWrapper ]; 57 buildInputs = [ gnu-efi_3 ]; 58 59 hardeningDisable = [ "stackprotector" ]; 60 61 makeFlags = [ 62 "prefix=" 63 "EFIINC=${gnu-efi_3}/include/efi" 64 "EFILIB=${gnu-efi_3}/lib" 65 "GNUEFILIB=${gnu-efi_3}/lib" 66 "EFICRT0=${gnu-efi_3}/lib" 67 "HOSTARCH=${hostarch}" 68 "ARCH=${hostarch}" 69 ] 70 ++ lib.optional stdenv.hostPlatform.isAarch64 [ 71 # aarch64 is special for GNU-EFI, see BUILDING.txt 72 "GNUEFI_ARM64_TARGET_SUPPORT=y" 73 ]; 74 75 buildFlags = [ 76 "gnuefi" 77 "fs_gnuefi" 78 ]; 79 80 installPhase = '' 81 runHook preInstall 82 83 install -d $out/bin/ 84 install -d $out/share/refind/drivers_${efiPlatform}/ 85 install -d $out/share/refind/tools_${efiPlatform}/ 86 install -d $out/share/refind/docs/html/ 87 install -d $out/share/refind/docs/Styles/ 88 install -d $out/share/refind/fonts/ 89 install -d $out/share/refind/icons/ 90 install -d $out/share/refind/images/ 91 install -d $out/share/refind/keys/ 92 93 # refind uefi app 94 install -D -m0644 refind/refind_${efiPlatform}.efi $out/share/refind/refind_${efiPlatform}.efi 95 96 # uefi drivers 97 install -D -m0644 drivers_${efiPlatform}/*.efi $out/share/refind/drivers_${efiPlatform}/ 98 99 # uefi apps 100 install -D -m0644 gptsync/gptsync_${efiPlatform}.efi $out/share/refind/tools_${efiPlatform}/gptsync_${efiPlatform}.efi 101 102 # helper scripts 103 install -D -m0755 refind-install $out/bin/refind-install 104 install -D -m0755 mkrlconf $out/bin/refind-mkrlconf 105 install -D -m0755 mvrefind $out/bin/refind-mvrefind 106 install -D -m0755 fonts/mkfont.sh $out/bin/refind-mkfont 107 108 # sample config files 109 install -D -m0644 refind.conf-sample $out/share/refind/refind.conf-sample 110 111 # docs 112 install -D -m0644 docs/refind/* $out/share/refind/docs/html/ 113 install -D -m0644 docs/Styles/* $out/share/refind/docs/Styles/ 114 install -D -m0644 README.txt $out/share/refind/docs/README.txt 115 install -D -m0644 NEWS.txt $out/share/refind/docs/NEWS.txt 116 install -D -m0644 BUILDING.txt $out/share/refind/docs/BUILDING.txt 117 install -D -m0644 CREDITS.txt $out/share/refind/docs/CREDITS.txt 118 119 # fonts 120 install -D -m0644 fonts/* $out/share/refind/fonts/ 121 rm -f $out/share/refind/fonts/mkfont.sh 122 123 # icons 124 install -D -m0644 icons/*.png $out/share/refind/icons/ 125 126 # images 127 install -D -m0644 images/*.{png,bmp} $out/share/refind/images/ 128 129 # keys 130 install -D -m0644 keys/* $out/share/refind/keys/ 131 132 # Fix variable definition of 'RefindDir' which is used to locate ressource files. 133 sed -i "s,\bRefindDir=\"\$This.*,RefindDir=$out/share/refind,g" $out/bin/refind-install 134 135 runHook postInstall 136 ''; 137 138 postInstall = '' 139 wrapProgram $out/bin/refind-install \ 140 --prefix PATH : ${ 141 lib.makeBinPath ( 142 [ 143 efibootmgr 144 openssl 145 ] 146 ++ lib.optional withSbsigntool sbsigntool 147 ) 148 } 149 wrapProgram $out/bin/refind-mvrefind \ 150 --prefix PATH : ${lib.makeBinPath [ efibootmgr ]} 151 ''; 152 153 passthru.tests = { 154 uefiCdrom = nixosTests.boot.uefiCdrom; 155 }; 156 157 meta = with lib; { 158 description = "Graphical {,U}EFI boot manager"; 159 longDescription = '' 160 rEFInd is a graphical boot manager for EFI- and UEFI-based 161 computers, such as all Intel-based Macs and recent (most 2011 162 and later) PCs. rEFInd presents a boot menu showing all the EFI 163 boot loaders on the EFI-accessible partitions, and optionally 164 BIOS-bootable partitions on Macs. EFI-compatible OSes, including 165 Linux, provide boot loaders that rEFInd can detect and 166 launch. rEFInd can launch Linux EFI boot loaders such as ELILO, 167 GRUB Legacy, GRUB 2, and 3.3.0 and later kernels with EFI stub 168 support. EFI filesystem drivers for ext2/3/4fs, ReiserFS, HFS+, 169 and ISO-9660 enable rEFInd to read boot loaders from these 170 filesystems, too. rEFInd's ability to detect boot loaders at 171 runtime makes it very easy to use, particularly when paired with 172 Linux kernels that provide EFI stub support. 173 ''; 174 homepage = "http://refind.sourceforge.net/"; 175 maintainers = with maintainers; [ johnrtitor ]; 176 platforms = [ 177 "i686-linux" 178 "x86_64-linux" 179 "aarch64-linux" 180 ]; 181 license = licenses.gpl3Plus; 182 }; 183 184}