about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWeijia Wang <9713184+wegank@users.noreply.github.com>2023-04-28 22:46:51 +0300
committerWeijia Wang <9713184+wegank@users.noreply.github.com>2023-04-28 22:46:51 +0300
commit670fc54922d520f6a7f9dbd0f7f7d595aba1713a (patch)
tree92daa6a16357aa2470fdba952829d031a2fcc8e7
parent4f9626b6dd098154c6e0ead13855fe01a8829186 (diff)
apfs-fuse: add darwin support
-rw-r--r--pkgs/tools/filesystems/apfs-fuse/default.nix20
1 files changed, 17 insertions, 3 deletions
diff --git a/pkgs/tools/filesystems/apfs-fuse/default.nix b/pkgs/tools/filesystems/apfs-fuse/default.nix
index 4abea4a242361..0beffca1a54ee 100644
--- a/pkgs/tools/filesystems/apfs-fuse/default.nix
+++ b/pkgs/tools/filesystems/apfs-fuse/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchFromGitHub, fuse3, bzip2, zlib, attr, cmake }:
+{ lib, stdenv, fetchFromGitHub, fuse, fuse3, bzip2, zlib, attr, cmake }:
 
 stdenv.mkDerivation {
   pname = "apfs-fuse-unstable";
@@ -12,9 +12,23 @@ stdenv.mkDerivation {
     fetchSubmodules = true;
   };
 
-  buildInputs = [ fuse3 bzip2 zlib attr ];
+  postPatch = lib.optionalString stdenv.isDarwin ''
+    substituteInPlace CMakeLists.txt \
+      --replace "/usr/local/lib/libosxfuse.dylib" "fuse"
+  '';
+
   nativeBuildInputs = [ cmake ];
 
+  buildInputs = [
+    (if stdenv.isDarwin then fuse else fuse3)
+    bzip2
+    zlib
+  ] ++ lib.optional stdenv.isLinux attr;
+
+  cmakeFlags = lib.optional stdenv.isDarwin "-DUSE_FUSE3=OFF";
+
+  env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-DUSE_FUSE2";
+
   postFixup = ''
     ln -s $out/bin/apfs-fuse $out/bin/mount.fuse.apfs-fuse
   '';
@@ -24,7 +38,7 @@ stdenv.mkDerivation {
     description = "FUSE driver for APFS (Apple File System)";
     license     = licenses.gpl2Plus;
     maintainers = with maintainers; [ ealasu ];
-    platforms   = platforms.linux;
+    platforms   = platforms.unix;
   };
 
 }