diff --git a/pkgs/tools/system/pdisk/default.nix b/pkgs/tools/system/pdisk/default.nix new file mode 100644 index 00000000000..87fc683063c --- /dev/null +++ b/pkgs/tools/system/pdisk/default.nix @@ -0,0 +1,88 @@ +{ stdenv +, lib +, fetchzip +, fetchpatch +, installShellFiles +, libbsd +, CoreFoundation +, IOKit +}: + +stdenv.mkDerivation rec { + pname = "pdisk"; + version = "0.9"; + + src = fetchzip { + url = "https://opensource.apple.com/tarballs/pdisk/pdisk-${lib.versions.minor version}.tar.gz"; + sha256 = "sha256-+gBgnk/1juEHE0nXaz7laUaH7sxrX5SzsLGr0PHsdHs="; + }; + + patches = [ + # Fix makefile for Unix + (fetchpatch { + url = "https://aur.archlinux.org/cgit/aur.git/plain/makefile.patch?h=pdisk&id=39dc371712d2f7dbd38f6e8ddc6ba661faa1a7a9"; + sha256 = "sha256-mLFclu8IlDN/gxNTI7Kei6ARketlAhJRu8ForFUzFU0="; + }) + # Fix lseek usage in file_media.c + (fetchpatch { + url = "https://aur.archlinux.org/cgit/aur.git/plain/file_media.c.patch?h=pdisk&id=39dc371712d2f7dbd38f6e8ddc6ba661faa1a7a9"; + sha256 = "sha256-CCq5fApwx6w1GKDrgP+0nUdQy/5z5ON7/fdp4M63nko="; + }) + # Fix open_partition_map call in cvt_pt.c + (fetchpatch { + url = "https://aur.archlinux.org/cgit/aur.git/plain/cvt_pt.c.patch?h=pdisk&id=39dc371712d2f7dbd38f6e8ddc6ba661faa1a7a9"; + sha256 = "sha256-jScPfzt9/fQHkf2MfHLvYsh/Rw2NZZXkzZiiVo8F5Mc="; + }) + # Replace removed sys_nerr and sys_errlist with strerror + (fetchpatch { + url = "https://aur.archlinux.org/cgit/aur.git/plain/linux_strerror.patch?h=pdisk&id=&id=d0c930ea8bcac008bbd0ade1811133a625caea54"; + sha256 = "sha256-HGJIS+vTn6456KtaETutIgTPPBm2C9OHf1anG8yaJPo="; + }) + ]; + + postPatch = '' + substituteInPlace makefile \ + --replace 'cc' '${stdenv.cc.targetPrefix}cc' + '' + lib.optionalString stdenv.hostPlatform.isDarwin '' + substituteInPlace makefile \ + --replace '-lbsd' '-framework CoreFoundation -framework IOKit' + ''; + + nativeBuildInputs = [ + installShellFiles + ]; + + buildInputs = lib.optionals (!stdenv.hostPlatform.isDarwin) [ + libbsd + ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [ + CoreFoundation + IOKit + ]; + + NIX_CFLAGS_COMPILE = "-D_GNU_SOURCE"; + + enableParallelBuilding = true; + + installPhase = '' + runHook preInstall + + install -Dm755 cvt_pt $out/bin/cvt_pt + install -Dm755 pdisk $out/bin/pdisk + + installManPage pdisk.8 + install -Dm644 pdisk.html $out/share/doc/pdisk/pdisk.html + + runHook postInstall + ''; + + meta = with lib; { + description = "A low-level Apple partition table editor for Linux, OSS Apple version"; + homepage = "https://github.com/apple-oss-distributions/pdisk"; + license = with licenses; [ + hpnd # original license statements seems to match this (in files that are shared with mac-fdisk) + apsl10 # new files + ]; + maintainers = with maintainers; [ OPNA2608 ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c4a0339bdc0..d2c81817f3d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7419,6 +7419,10 @@ with pkgs; partimage = callPackage ../tools/backup/partimage { }; + pdisk = callPackage ../tools/system/pdisk { + inherit (darwin.apple_sdk.frameworks) CoreFoundation IOKit; + }; + pgf_graphics = callPackage ../tools/graphics/pgf { }; pgformatter = callPackage ../development/tools/pgformatter { };