Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 fetchpatch,
6 installShellFiles,
7 libbsd,
8}:
9
10stdenv.mkDerivation (finalAttrs: {
11 pname = "pdisk";
12 version = "0.10";
13
14 src = fetchFromGitHub {
15 owner = "apple-oss-distributions";
16 repo = "pdisk";
17 tag = "pdisk-${lib.versions.minor finalAttrs.version}";
18 hash = "sha256-+gBgnk/1juEHE0nXaz7laUaH7sxrX5SzsLGr0PHsdHs=";
19 };
20
21 patches = [
22 # Fix makefile for Unix
23 (fetchpatch {
24 url = "https://aur.archlinux.org/cgit/aur.git/plain/makefile.patch?h=pdisk&id=39dc371712d2f7dbd38f6e8ddc6ba661faa1a7a9";
25 sha256 = "sha256-mLFclu8IlDN/gxNTI7Kei6ARketlAhJRu8ForFUzFU0=";
26 })
27 # Fix lseek usage in file_media.c
28 (fetchpatch {
29 url = "https://aur.archlinux.org/cgit/aur.git/plain/file_media.c.patch?h=pdisk&id=39dc371712d2f7dbd38f6e8ddc6ba661faa1a7a9";
30 sha256 = "sha256-CCq5fApwx6w1GKDrgP+0nUdQy/5z5ON7/fdp4M63nko=";
31 })
32 # Fix open_partition_map call in cvt_pt.c
33 (fetchpatch {
34 url = "https://aur.archlinux.org/cgit/aur.git/plain/cvt_pt.c.patch?h=pdisk&id=39dc371712d2f7dbd38f6e8ddc6ba661faa1a7a9";
35 sha256 = "sha256-jScPfzt9/fQHkf2MfHLvYsh/Rw2NZZXkzZiiVo8F5Mc=";
36 })
37 # Replace removed sys_nerr and sys_errlist with strerror
38 (fetchpatch {
39 url = "https://aur.archlinux.org/cgit/aur.git/plain/linux_strerror.patch?h=pdisk&id=d0c930ea8bcac008bbd0ade1811133a625caea54";
40 sha256 = "sha256-HGJIS+vTn6456KtaETutIgTPPBm2C9OHf1anG8yaJPo=";
41 })
42
43 # Fix missing includes on Linux
44 ./cmdline.patch
45 ];
46
47 postPatch = ''
48 substituteInPlace makefile \
49 --replace-fail 'cc' '${stdenv.cc.targetPrefix}cc'
50 ''
51 + lib.optionalString stdenv.hostPlatform.isDarwin ''
52 substituteInPlace makefile \
53 --replace-fail '-lbsd' '-framework CoreFoundation -framework IOKit'
54 '';
55
56 strictDeps = true;
57
58 nativeBuildInputs = [
59 installShellFiles
60 ];
61
62 buildInputs = lib.optionals (!stdenv.hostPlatform.isDarwin) [
63 libbsd
64 ];
65
66 env.NIX_CFLAGS_COMPILE = "-D_GNU_SOURCE";
67
68 enableParallelBuilding = true;
69
70 installPhase = ''
71 runHook preInstall
72
73 for exe in pdisk cvt_pt; do
74 install -Dm755 -t $out/bin $exe
75 done
76
77 installManPage pdisk.8
78 install -Dm644 pdisk.html $out/share/doc/pdisk/pdisk.html
79
80 runHook postInstall
81 '';
82
83 meta = {
84 description = "Low-level Apple partition table editor for Linux, OSS Apple version";
85 homepage = "https://github.com/apple-oss-distributions/pdisk";
86 license = with lib.licenses; [
87 hpnd # original license statements seems to match this (in files that are shared with mac-fdisk)
88 apple-psl10 # new files
89 ];
90 mainProgram = "pdisk";
91 maintainers = with lib.maintainers; [ OPNA2608 ];
92 platforms = lib.platforms.unix;
93 };
94})