@ -1,15 +1,23 @@
{ stdenv , fetchurl , fetchpatch
, gnu-efi , efibootmgr , dosfstools , imagemagick } :
{ stdenv , fetchurl , fetchpatch , gnu-efi }:
assert ( stdenv . system == " x 8 6 _ 6 4 - l i n u x " || stdenv . system == " i 6 8 6 - l i n u x " ) ;
let
archids = {
" x 8 6 _ 6 4 - l i n u x " = { hostarch = " x 8 6 _ 6 4 " ; efiPlatform = " x 6 4 " ; } ;
" i 6 8 6 - l i n u x " = rec { hostarch = " i a 3 2 " ; efiPlatform = hostarch ; } ;
} ;
stdenv . mkDerivation rec {
inherit
( archids . ${ stdenv . system } or ( throw " u n s u p p o r t e d s y s t e m : ${ stdenv . system } " ) )
hostarch efiPlatform ;
in
name = " r e f i n d - ${ meta . version } " ;
srcName = " r e f i n d - s r c - ${ meta . version } " ;
stdenv . mkDerivation rec {
name = " r e f i n d - ${ version } " ;
version = " 0 . 1 0 . 3 " ;
srcName = " r e f i n d - s r c - ${ version } " ;
src = fetchurl {
url = " m i r r o r : / / s o u r c e f o r g e / p r o j e c t / r e f i n d / ${ meta . version } / ${ srcName } . t a r . g z " ;
url = " m i r r o r : / / s o u r c e f o r g e / p r o j e c t / r e f i n d / ${ version } / ${ srcName } . t a r . g z " ;
sha256 = " 1 r 2 q p 2 9 m z 0 8 l x 3 6 i 7 x 5 2 i 2 5 9 8 7 7 3 b x v f h w r y d 9 5 4 s s q 2 b a i f j a v 5 " ;
} ;
@ -21,33 +29,31 @@ stdenv.mkDerivation rec {
} )
] ;
buildInputs = [ gnu-efi efibootmgr dosfstools imagemagick ] ;
buildInputs = [ gnu-efi ] ;
hardeningDisable = [ " s t a c k p r o t e c t o r " ] ;
HOSTARCH =
if stdenv . system == " x 8 6 _ 6 4 - l i n u x " then " x 6 4 "
else if stdenv . system == " i 6 8 6 - l i n u x " then " i a 3 2 "
else " n u l l " ;
postPatch = ''
sed - e ' s | - DEFI_FUNCTION_WRAPPER | - DEFI_FUNCTION_WRAPPER - maccumulate-outgoing-args | g' - i Make . common
sed - e ' s | - DEFIX64 | - DEFIX64 - maccumulate-outgoing-args | g' - i Make . common
sed - e ' s | - m64 | - maccumulate-outgoing-args - m64 | g' - i filesystems/Make.gnuefi
'' ;
buildPhase =
let ldScript =
if stdenv . system == " x 8 6 _ 6 4 - l i n u x " then " e l f _ x 8 6 _ 6 4 _ e f i . l d s "
else if stdenv . system == " i 6 8 6 - l i n u x " then " e l f _ i a 3 2 _ e f i . l d s " else " n u l l " ;
in ''
make prefix = EFIINC = $ { gnu-efi } /include/efi EFILIB = $ { gnu-efi } /lib GNUEFILIB = $ { gnu-efi } /lib EFICRT0 = $ { gnu-efi } /lib LDSCRIPT = $ { gnu-efi } /lib / $ { ldScript } gnuefi fs_gnuefi
'' ;
makeFlags =
[ " p r e f i x = "
" E F I I N C = ${ gnu-efi } / i n c l u d e / e f i "
" E F I L I B = ${ gnu-efi } / l i b "
" G N U E F I L I B = ${ gnu-efi } / l i b "
" E F I C R T 0 = ${ gnu-efi } / l i b "
" H O S T A R C H = ${ hostarch } "
] ;
buildFlags = [ " g n u e f i " " f s _ g n u e f i " ] ;
installPhase = ''
install - d $ out/bin /
install - d $ out/share/refind/drivers_ $ { HOSTARCH } /
install - d $ out/share/refind/tools_ $ { HOSTARCH } /
install - d $ out/share/refind/drivers_ $ { efiPlatform } /
install - d $ out/share/refind/tools_ $ { efiPlatform } /
install - d $ out/share/refind/docs/html /
install - d $ out/share/refind/docs/Styles /
install - d $ out/share/refind/fonts /
@ -56,16 +62,16 @@ stdenv.mkDerivation rec {
install - d $ out/share/refind/keys /
# refind uefi app
install - D - m0644 refind/refind_ $ { HOSTARCH } . efi $ out/share/refind/refind_ $ { HOSTARCH } . efi
install - D - m0644 refind/refind_ $ { efiPlatform } . efi $ out/share/refind/refind_ $ { efiPlatform } . efi
# uefi drivers
install - D - m0644 drivers_ $ { HOSTARCH } /* . e f i $ o u t / s h a r e / r e f i n d / d r i v e r s _ $ { H O S T A R C H } /
install - D - m0644 drivers_ $ { efiPlatform } /* . e f i $ o u t / s h a r e / r e f i n d / d r i v e r s _ $ { e f i P l a t f o r m } /
# uefi apps
install - D - m0644 gptsync/gptsync_ $ { HOSTARCH } . efi $ out/share/refind/tools_ $ { HOSTARCH } /gptsync_ $ { HOSTARCH } . efi
install - D - m0644 gptsync/gptsync_ $ { efiPlatform } . efi $ out/share/refind/tools_ $ { efiPlatform } /gptsync_ $ { efiPlatform } . efi
# helper scripts
install - D - m0755 refind-install $ out/bin /refind-install
install - D - m0755 refind-install $ out/share/refind /refind-install
install - D - m0755 mkrlconf $ out/bin/refind-mkrlconf
install - D - m0755 mvrefind $ out/bin/refind-mvrefind
install - D - m0755 fonts/mkfont.sh $ out/bin/refind-mkfont
@ -94,16 +100,26 @@ stdenv.mkDerivation rec {
# keys
install - D - m0644 keys /* $ o u t / s h a r e / r e f i n d / k e y s /
# fix sharp-bang paths
patchShebangs $ out/bin/refind- *
# Post-install fixes
sed - e " s | ^ T h i s D i r = . * | T h i s D i r = $ o u t / s h a r e / r e f i n d / | g " - i $ out/bin/refind-install
sed - e " s | ^ R e f i n d D i r = . * | R e f i n d D i r = $ o u t / s h a r e / r e f i n d / | g " - i $ out/bin/refind-install
# The refind-install script assumes that all resource files are
# installed under the same directory as the script itself. To avoid
# having to patch around this assumption, generate a wrapper that
# cds into $out/share/refind and executes the real script from
# there.
cat > $ out/bin/refind-install < < EOF
#! ${stdenv.shell}
cd $ out/share/refind && exec - a $ out/bin/refind-install ./refind-install \ $ *
EOF
chmod + x $ out/bin/refind-install
# Patch uses of `which`. We could patch in calls to efibootmgr,
# openssl, convert, and openssl, but that would greatly enlarge
# refind's closure (from ca 28MB to over 400MB).
sed - i ' s , ` which \ ( . * \ ) ` , ` type - p \ 1 ` , g' $ out/share/refind/refind-install
sed - i ' s , ` which \ ( . * \ ) ` , ` type - p \ 1 ` , g' $ out/bin/refind-mvrefind
sed - i ' s , ` which \ ( . * \ ) ` , ` type - p \ 1 ` , g' $ out/bin/refind-mkfont
'' ;
meta = with stdenv . lib ; {
version = " 0 . 1 0 . 3 " ;
description = " A g r a p h i c a l { , U } E F I b o o t m a n a g e r " ;
longDescription = ''
rEFInd is a graphical boot manager for EFI- and UEFI-based