2022-09-28 19:23:12 +02:00
{ stdenv
, lib
, fetchzip
, fetchpatch
, installShellFiles
} :
stdenv . mkDerivation rec {
pname = " m a c - f d i s k " ;
version = " 0 . 1 . 1 6 " ;
src = fetchzip {
url = " h t t p s : / / d e b . d e b i a n . o r g / d e b i a n / p o o l / m a i n / m / m a c - f d i s k / m a c - f d i s k _ 0 . 1 . o r i g . t a r . g z " ;
sha256 = " s h a 2 5 6 - p Y N y h P v R K d I j e 0 R p a y 0 O z m r k G c l + / J O h M v 7 r + 2 L Z k / Q = " ;
} ;
patches = [
# Debian's changeset, extracted into a patch
( fetchpatch {
url = " h t t p s : / / g i t . a d e l i e l i n u x . o r g / a d e l i e / p a c k a g e s / - / r a w / 1 b 7 0 8 c 8 a 9 0 e 3 5 4 8 c 4 9 5 4 c 6 3 6 7 a 9 3 7 6 f 7 6 f 3 7 4 6 b d / u s e r / m a c - f d i s k / m a c - f d i s k - 0 . 1 - d e b i a n . p a t c h " ;
sha256 = " s h a 2 5 6 - a 9 p G F + U s F e Z i X g r a c m T 4 a n q g p m c G c S / W 3 j G t F z H Z t t 4 = " ;
} )
# Include a lot more headers and remove a bunch of braindead __linux__ checks
( fetchpatch {
url = " h t t p s : / / g i t . a d e l i e l i n u x . o r g / a d e l i e / p a c k a g e s / - / r a w / 1 f a 4 c 8 8 e e 2 1 8 6 6 e e b 0 f e a e 8 f 6 b 0 b f 6 0 9 a 0 4 7 1 1 c c / u s e r / m a c - f d i s k / m a c - f d i s k - 0 . 1 - h e a d e r s . p a t c h " ;
sha256 = " s h a 2 5 6 - F I k 9 K + l P + 3 e 1 p g m N f y m T d p d S o T p B D v 2 9 k m w Y g q Y w W Q w = " ;
} )
# Add support for more architectures
( fetchpatch {
url = " h t t p s : / / g i t . a d e l i e l i n u x . o r g / a d e l i e / p a c k a g e s / - / r a w / 1 b 7 0 8 c 8 a 9 0 e 3 5 4 8 c 4 9 5 4 c 6 3 6 7 a 9 3 7 6 f 7 6 f 3 7 4 6 b d / u s e r / m a c - f d i s k / m a c - f d i s k - 0 . 1 - m o r e - a r c h e s . p a t c h " ;
sha256 = " s h a 2 5 6 - H N R m z E T U m K f Z Q F r j g 6 Y / H P w U n L k 0 v O 5 D o k f U 4 u m d O m 0 = " ;
} )
# From p16 (source?), adjusts some types & fixes PPC64 support
( fetchpatch {
url = " h t t p s : / / g i t . a d e l i e l i n u x . o r g / a d e l i e / p a c k a g e s / - / r a w / 1 f a 4 c 8 8 e e 2 1 8 6 6 e e b 0 f e a e 8 f 6 b 0 b f 6 0 9 a 0 4 7 1 1 c c / u s e r / m a c - f d i s k / m a c - f d i s k - 0 . 1 _ p 1 6 - p p c 6 4 . p a t c h " ;
sha256 = " s h a 2 5 6 - G K 0 n f g a 5 9 n O X o t k b K I + 2 e j A 9 T t y Z U w D I x u X W F G G b e F g = " ;
} )
# From p16 (source?), makes some inlines static
( fetchpatch {
url = " h t t p s : / / g i t . a d e l i e l i n u x . o r g / a d e l i e / p a c k a g e s / - / r a w / 1 f a 4 c 8 8 e e 2 1 8 6 6 e e b 0 f e a e 8 f 6 b 0 b f 6 0 9 a 0 4 7 1 1 c c / u s e r / m a c - f d i s k / m a c - f d i s k - 0 . 1 _ p 1 6 - p r o p e r - i n l i n e . p a t c h " ;
sha256 = " s h a 2 5 6 - w r 2 t e K p m 0 F y q N u d K Y l T D 4 9 p T F D i s 3 3 F o + 0 L U L N Y I J k o = " ;
} )
# Adds x86_64 support
( fetchpatch {
url = " h t t p s : / / g i t . a d e l i e l i n u x . o r g / a d e l i e / p a c k a g e s / - / r a w / 1 b 7 0 8 c 8 a 9 0 e 3 5 4 8 c 4 9 5 4 c 6 3 6 7 a 9 3 7 6 f 7 6 f 3 7 4 6 b d / u s e r / m a c - f d i s k / m a c - f d i s k - a m d 6 4 . p a t c h " ;
sha256 = " s h a 2 5 6 - i O 4 / s Y 5 s G K Q y y m M m A O b / T l C c 9 i d 2 q g E D w 7 E 8 p F Z p s H I = " ;
} )
# Fix missing header in fdisk.c on musl
( fetchpatch {
url = " h t t p s : / / g i t . a d e l i e l i n u x . o r g / a d e l i e / p a c k a g e s / - / r a w / 1 f a 4 c 8 8 e e 2 1 8 6 6 e e b 0 f e a e 8 f 6 b 0 b f 6 0 9 a 0 4 7 1 1 c c / u s e r / m a c - f d i s k / m a c - f d i s k - f d i s k - h e a d e r - m u s l . p a t c h " ;
sha256 = " s h a 2 5 6 - m K B V j v L K t x K P A D e o P q p 1 7 Y d J 1 Q W j 2 e n A Y h K K S q T n Q 4 4 = " ;
} )
# Support disks >550GB
( fetchpatch {
url = " h t t p s : / / g i t . a d e l i e l i n u x . o r g / a d e l i e / p a c k a g e s / - / r a w / 1 f a 4 c 8 8 e e 2 1 8 6 6 e e b 0 f e a e 8 f 6 b 0 b f 6 0 9 a 0 4 7 1 1 c c / u s e r / m a c - f d i s k / m a c - f d i s k - l a r g e - d i s k - s u p p o r t . p a t c h " ;
sha256 = " s h a 2 5 6 - I X Z Z d o z q Z K y Z E z 8 7 Z z B 8 J o f 2 2 G g v H f 4 G a X B q S K n 8 s u 8 = " ;
} )
# Enable Large File Support (>2GiB)
( fetchpatch {
url = " h t t p s : / / g i t . a d e l i e l i n u x . o r g / a d e l i e / p a c k a g e s / - / r a w / 1 f a 4 c 8 8 e e 2 1 8 6 6 e e b 0 f e a e 8 f 6 b 0 b f 6 0 9 a 0 4 7 1 1 c c / u s e r / m a c - f d i s k / m a c - f d i s k - l a r g e r t h a n 2 g b . p a t c h " ;
sha256 = " s h a 2 5 6 - A T K 7 Q Y X V 7 B O k 8 i I F e X Y 8 g + Z H L u u h w w 9 p c r q O M D n / o L M = " ;
} )
# Fix compilation on non-glibc
( fetchpatch {
url = " h t t p s : / / g i t . a d e l i e l i n u x . o r g / a d e l i e / p a c k a g e s / - / r a w / 1 f a 4 c 8 8 e e 2 1 8 6 6 e e b 0 f e a e 8 f 6 b 0 b f 6 0 9 a 0 4 7 1 1 c c / u s e r / m a c - f d i s k / m a c - f d i s k - n o n - g l i b c - s u p p o r t . p a t c h " ;
sha256 = " s h a 2 5 6 - C B Z U K f 7 d P v v p u G 5 L + S I 1 F Q 4 W 7 / f D g e K X H U M F k J N u / M Y = " ;
} )
# Flush stdout after printing prompt for better UX
( fetchpatch {
url = " h t t p s : / / g i t . a d e l i e l i n u x . o r g / a d e l i e / p a c k a g e s / - / r a w / 6 5 6 a e 6 b f 9 f 8 a 6 4 a e e 9 5 c 4 7 9 7 b 2 0 b f e 7 1 3 6 2 7 f 1 f 4 / u s e r / m a c - f d i s k / f l u s h - s t d o u t . p a t c h " ;
sha256 = " s h a 2 5 6 - k 7 + U P i U f / o C Q d D h x D c C + F R w k x S 8 9 W S s Y z F w 6 f U B / 1 0 I = " ;
} )
] ;
nativeBuildInputs = [
installShellFiles
] ;
enableParallelBuilding = true ;
2023-02-19 20:23:32 +01:00
env . NIX_CFLAGS_COMPILE = " - D _ G N U _ S O U R C E " ;
2022-09-28 19:23:12 +02:00
hardeningDisable = [ " f o r m a t " ] ;
installPhase = ''
runHook preInstall
install - Dm755 pdisk $ out/sbin/mac-fdisk
install - Dm755 fdisk $ out/sbin/pmac-fdisk
for manpage in { , p } mac-fdisk .8 ; do
mv " $ m a n p a g e " . in $ manpage
installManPage $ manpage
done
runHook postInstall
'' ;
meta = with lib ; {
description = " 6 8 K a n d P o w e r P C M a c d i s k p a r t i t i o n i n g u t i l i t y , A d é l i e L i n u x v e r s i o n " ;
# http://ftp.mklinux.apple.com:/pub/Other_Tools/ but that one's looong dead, link goes to the patch compilation we're using
homepage = " h t t p s : / / g i t . a d e l i e l i n u x . o r g / a d e l i e / p a c k a g e s / - / t r e e / m a s t e r / u s e r / m a c - f d i s k " ;
license = with licenses ; [
hpnd # original license statements seems to match this (in files that are shared with pdisk)
gpl1Plus # fdisk.c
] ;
maintainers = with maintainers ; [ OPNA2608 ] ;
# the toolchain that's being expected for Mac support (SCSI.h from Universal Headers 2.0, SIOUX.h from Metrowerks CoreWarrior) is ancient, unsure about BSDs
platforms = platforms . linux ;
badPlatforms = platforms . aarch64 ; # missing some platform definitions
} ;
}