about summary refs log tree commit diff
path: root/pkgs/tools
diff options
context:
space:
mode:
authorStanisław Pitucha <git@viraptor.info>2023-03-22 21:30:23 +1100
committerStanisław Pitucha <git@viraptor.info>2023-03-23 07:18:42 +1100
commit6d903cec7e3040a694c2c24c395f401db735545a (patch)
tree148a83bb4f898e025646f278db7004b3d4317618 /pkgs/tools
parent8be838254badb578300520f61091a86fd0c7d328 (diff)
downloadnixlib-6d903cec7e3040a694c2c24c395f401db735545a.tar
nixlib-6d903cec7e3040a694c2c24c395f401db735545a.tar.gz
nixlib-6d903cec7e3040a694c2c24c395f401db735545a.tar.bz2
nixlib-6d903cec7e3040a694c2c24c395f401db735545a.tar.lz
nixlib-6d903cec7e3040a694c2c24c395f401db735545a.tar.xz
nixlib-6d903cec7e3040a694c2c24c395f401db735545a.tar.zst
nixlib-6d903cec7e3040a694c2c24c395f401db735545a.zip
cdrkit: fix darwin build
Fix source issues and required deps.
Diffstat (limited to 'pkgs/tools')
-rw-r--r--pkgs/tools/cd-dvd/cdrkit/default.nix28
1 files changed, 25 insertions, 3 deletions
diff --git a/pkgs/tools/cd-dvd/cdrkit/default.nix b/pkgs/tools/cd-dvd/cdrkit/default.nix
index efa663809949..de54827071c6 100644
--- a/pkgs/tools/cd-dvd/cdrkit/default.nix
+++ b/pkgs/tools/cd-dvd/cdrkit/default.nix
@@ -1,4 +1,4 @@
-{lib, stdenv, fetchurl, cmake, libcap, zlib, bzip2, perl}:
+{lib, stdenv, fetchurl, cmake, libcap, zlib, bzip2, perl, iconv, darwin}:
 
 stdenv.mkDerivation rec {
   pname = "cdrkit";
@@ -10,7 +10,9 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ cmake ];
-  buildInputs = [ libcap zlib bzip2 perl ];
+  buildInputs = [ zlib bzip2 perl ] ++
+    lib.optionals stdenv.isLinux [ libcap ] ++
+    lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Carbon IOKit iconv ]);
 
   hardeningDisable = [ "format" ];
   env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isMusl "-D__THROW=";
@@ -18,11 +20,31 @@ stdenv.mkDerivation rec {
   # efi-boot-patch extracted from http://arm.koji.fedoraproject.org/koji/rpminfo?rpmID=174244
   patches = [ ./include-path.patch ./cdrkit-1.1.9-efi-boot.patch ./cdrkit-1.1.11-fno-common.patch ];
 
+  postPatch = lib.optionalString stdenv.isDarwin ''
+    substituteInPlace libusal/scsi-mac-iokit.c \
+      --replace "IOKit/scsi-commands/SCSITaskLib.h" "IOKit/scsi/SCSITaskLib.h"
+    substituteInPlace genisoimage/sha256.c \
+      --replace "<endian.h>" "<machine/endian.h>"
+    substituteInPlace genisoimage/sha512.c \
+      --replace "<endian.h>" "<machine/endian.h>"
+    substituteInPlace genisoimage/sha256.h \
+      --replace "__THROW" ""
+    substituteInPlace genisoimage/sha512.h \
+      --replace "__THROW" ""
+  '';
+
   preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
     substituteInPlace include/xconfig.h.in \
         --replace "#define HAVE_RCMD 1" "#undef HAVE_RCMD"
   '';
 
+  postConfigure = lib.optionalString stdenv.isDarwin ''
+    for f in */CMakeFiles/*.dir/link.txt ; do
+      substituteInPlace "$f" \
+        --replace "-lrt" "-framework IOKit"
+    done
+  '';
+
   postInstall = ''
     # file name compatibility with the old cdrecord (growisofs wants this name)
     ln -s $out/bin/genisoimage $out/bin/mkisofs
@@ -49,6 +71,6 @@ stdenv.mkDerivation rec {
 
     homepage = "http://cdrkit.org/";
     license = lib.licenses.gpl2;
-    platforms = lib.platforms.linux;
+    platforms = lib.platforms.unix;
   };
 }